links-notation 0.8.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,1322 @@
1
+ // @generated by Peggy 5.0.6.
2
+ //
3
+ // https://peggyjs.org/
4
+
5
+
6
+ class peg$SyntaxError extends SyntaxError {
7
+ constructor(message, expected, found, location) {
8
+ super(message);
9
+ this.expected = expected;
10
+ this.found = found;
11
+ this.location = location;
12
+ this.name = "SyntaxError";
13
+ }
14
+
15
+ format(sources) {
16
+ let str = "Error: " + this.message;
17
+ if (this.location) {
18
+ let src = null;
19
+ const st = sources.find(s => s.source === this.location.source);
20
+ if (st) {
21
+ src = st.text.split(/\r\n|\n|\r/g);
22
+ }
23
+ const s = this.location.start;
24
+ const offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
25
+ ? this.location.source.offset(s)
26
+ : s;
27
+ const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
28
+ if (src) {
29
+ const e = this.location.end;
30
+ const filler = "".padEnd(offset_s.line.toString().length, " ");
31
+ const line = src[s.line - 1];
32
+ const last = s.line === e.line ? e.column : line.length + 1;
33
+ const hatLen = (last - s.column) || 1;
34
+ str += "\n --> " + loc + "\n"
35
+ + filler + " |\n"
36
+ + offset_s.line + " | " + line + "\n"
37
+ + filler + " | " + "".padEnd(s.column - 1, " ")
38
+ + "".padEnd(hatLen, "^");
39
+ } else {
40
+ str += "\n at " + loc;
41
+ }
42
+ }
43
+ return str;
44
+ }
45
+
46
+ static buildMessage(expected, found) {
47
+ function hex(ch) {
48
+ return ch.codePointAt(0).toString(16).toUpperCase();
49
+ }
50
+
51
+ const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode")
52
+ ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu")
53
+ : null;
54
+ function unicodeEscape(s) {
55
+ if (nonPrintable) {
56
+ return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}");
57
+ }
58
+ return s;
59
+ }
60
+
61
+ function literalEscape(s) {
62
+ return unicodeEscape(s
63
+ .replace(/\\/g, "\\\\")
64
+ .replace(/"/g, "\\\"")
65
+ .replace(/\0/g, "\\0")
66
+ .replace(/\t/g, "\\t")
67
+ .replace(/\n/g, "\\n")
68
+ .replace(/\r/g, "\\r")
69
+ .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
70
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
71
+ }
72
+
73
+ function classEscape(s) {
74
+ return unicodeEscape(s
75
+ .replace(/\\/g, "\\\\")
76
+ .replace(/\]/g, "\\]")
77
+ .replace(/\^/g, "\\^")
78
+ .replace(/-/g, "\\-")
79
+ .replace(/\0/g, "\\0")
80
+ .replace(/\t/g, "\\t")
81
+ .replace(/\n/g, "\\n")
82
+ .replace(/\r/g, "\\r")
83
+ .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
84
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
85
+ }
86
+
87
+ const DESCRIBE_EXPECTATION_FNS = {
88
+ literal(expectation) {
89
+ return "\"" + literalEscape(expectation.text) + "\"";
90
+ },
91
+
92
+ class(expectation) {
93
+ const escapedParts = expectation.parts.map(
94
+ part => (Array.isArray(part)
95
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
96
+ : classEscape(part))
97
+ );
98
+
99
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : "");
100
+ },
101
+
102
+ any() {
103
+ return "any character";
104
+ },
105
+
106
+ end() {
107
+ return "end of input";
108
+ },
109
+
110
+ other(expectation) {
111
+ return expectation.description;
112
+ },
113
+ };
114
+
115
+ function describeExpectation(expectation) {
116
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
117
+ }
118
+
119
+ function describeExpected(expected) {
120
+ const descriptions = expected.map(describeExpectation);
121
+ descriptions.sort();
122
+
123
+ if (descriptions.length > 0) {
124
+ let j = 1;
125
+ for (let i = 1; i < descriptions.length; i++) {
126
+ if (descriptions[i - 1] !== descriptions[i]) {
127
+ descriptions[j] = descriptions[i];
128
+ j++;
129
+ }
130
+ }
131
+ descriptions.length = j;
132
+ }
133
+
134
+ switch (descriptions.length) {
135
+ case 1:
136
+ return descriptions[0];
137
+
138
+ case 2:
139
+ return descriptions[0] + " or " + descriptions[1];
140
+
141
+ default:
142
+ return descriptions.slice(0, -1).join(", ")
143
+ + ", or "
144
+ + descriptions[descriptions.length - 1];
145
+ }
146
+ }
147
+
148
+ function describeFound(found) {
149
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
150
+ }
151
+
152
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
153
+ }
154
+ }
155
+
156
+ function peg$parse(input, options) {
157
+ options = options !== undefined ? options : {};
158
+
159
+ const peg$FAILED = {};
160
+ const peg$source = options.grammarSource;
161
+
162
+ const peg$startRuleFunctions = {
163
+ document: peg$parsedocument,
164
+ };
165
+ let peg$startRuleFunction = peg$parsedocument;
166
+
167
+ const peg$c0 = ":";
168
+ const peg$c1 = "(";
169
+ const peg$c2 = ")";
170
+ const peg$c3 = "\"";
171
+ const peg$c4 = "'";
172
+ const peg$c5 = " ";
173
+
174
+ const peg$r0 = /^[^"]/;
175
+ const peg$r1 = /^[^']/;
176
+ const peg$r2 = /^[\r\n]/;
177
+ const peg$r3 = /^[ \t]/;
178
+ const peg$r4 = /^[ \t\n\r]/;
179
+ const peg$r5 = /^[^ \t\n\r(:)]/;
180
+
181
+ const peg$e0 = peg$literalExpectation(":", false);
182
+ const peg$e1 = peg$literalExpectation("(", false);
183
+ const peg$e2 = peg$literalExpectation(")", false);
184
+ const peg$e3 = peg$literalExpectation("\"", false);
185
+ const peg$e4 = peg$classExpectation(["\""], true, false, false);
186
+ const peg$e5 = peg$literalExpectation("'", false);
187
+ const peg$e6 = peg$classExpectation(["'"], true, false, false);
188
+ const peg$e7 = peg$literalExpectation(" ", false);
189
+ const peg$e8 = peg$classExpectation(["\r", "\n"], false, false, false);
190
+ const peg$e9 = peg$anyExpectation();
191
+ const peg$e10 = peg$classExpectation([" ", "\t"], false, false, false);
192
+ const peg$e11 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false);
193
+ const peg$e12 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
194
+
195
+ function peg$f0(links) { return links; }
196
+ function peg$f1() { return []; }
197
+ function peg$f2(fl, list) { popIndentation(); return [fl].concat(list || []); }
198
+ function peg$f3(l) { return l; }
199
+ function peg$f4(l) { return l; }
200
+ function peg$f5(e, l) {
201
+ return { id: e.id, values: e.values, children: l };
202
+ }
203
+ function peg$f6(e) { return e; }
204
+ function peg$f7(l) { return l; }
205
+ function peg$f8(i) { return { id: i }; }
206
+ function peg$f9(ml) { return ml; }
207
+ function peg$f10(il) { return il; }
208
+ function peg$f11(sl) { return sl; }
209
+ function peg$f12(fl) { return fl; }
210
+ function peg$f13(vl) { return vl; }
211
+ function peg$f14(value) { return value; }
212
+ function peg$f15(list) { return list; }
213
+ function peg$f16(value) { return value; }
214
+ function peg$f17(list) { return list; }
215
+ function peg$f18(id, v) { return { id: id, values: v }; }
216
+ function peg$f19(id, v) { return { id: id, values: v }; }
217
+ function peg$f20(v) { return { values: v }; }
218
+ function peg$f21(v) { return { values: v }; }
219
+ function peg$f22(id) { return { id: id, values: [] }; }
220
+ function peg$f23(chars) { return chars.join(''); }
221
+ function peg$f24(r) { return r.join(''); }
222
+ function peg$f25(r) { return r.join(''); }
223
+ function peg$f26(spaces) { return spaces.length > getCurrentIndentation(); }
224
+ function peg$f27(spaces) { pushIndentation(spaces); }
225
+ function peg$f28(spaces) { return checkIndentation(spaces); }
226
+ let peg$currPos = options.peg$currPos | 0;
227
+ let peg$savedPos = peg$currPos;
228
+ const peg$posDetailsCache = [{ line: 1, column: 1 }];
229
+ let peg$maxFailPos = peg$currPos;
230
+ let peg$maxFailExpected = options.peg$maxFailExpected || [];
231
+ let peg$silentFails = options.peg$silentFails | 0;
232
+
233
+ let peg$result;
234
+
235
+ if (options.startRule) {
236
+ if (!(options.startRule in peg$startRuleFunctions)) {
237
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
238
+ }
239
+
240
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
241
+ }
242
+
243
+ function text() {
244
+ return input.substring(peg$savedPos, peg$currPos);
245
+ }
246
+
247
+ function offset() {
248
+ return peg$savedPos;
249
+ }
250
+
251
+ function range() {
252
+ return {
253
+ source: peg$source,
254
+ start: peg$savedPos,
255
+ end: peg$currPos,
256
+ };
257
+ }
258
+
259
+ function location() {
260
+ return peg$computeLocation(peg$savedPos, peg$currPos);
261
+ }
262
+
263
+ function expected(description, location) {
264
+ location = location !== undefined
265
+ ? location
266
+ : peg$computeLocation(peg$savedPos, peg$currPos);
267
+
268
+ throw peg$buildStructuredError(
269
+ [peg$otherExpectation(description)],
270
+ input.substring(peg$savedPos, peg$currPos),
271
+ location
272
+ );
273
+ }
274
+
275
+ function error(message, location) {
276
+ location = location !== undefined
277
+ ? location
278
+ : peg$computeLocation(peg$savedPos, peg$currPos);
279
+
280
+ throw peg$buildSimpleError(message, location);
281
+ }
282
+
283
+ function peg$getUnicode(pos = peg$currPos) {
284
+ const cp = input.codePointAt(pos);
285
+ if (cp === undefined) {
286
+ return "";
287
+ }
288
+ return String.fromCodePoint(cp);
289
+ }
290
+
291
+ function peg$literalExpectation(text, ignoreCase) {
292
+ return { type: "literal", text, ignoreCase };
293
+ }
294
+
295
+ function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
296
+ return { type: "class", parts, inverted, ignoreCase, unicode };
297
+ }
298
+
299
+ function peg$anyExpectation() {
300
+ return { type: "any" };
301
+ }
302
+
303
+ function peg$endExpectation() {
304
+ return { type: "end" };
305
+ }
306
+
307
+ function peg$otherExpectation(description) {
308
+ return { type: "other", description };
309
+ }
310
+
311
+ function peg$computePosDetails(pos) {
312
+ let details = peg$posDetailsCache[pos];
313
+ let p;
314
+
315
+ if (details) {
316
+ return details;
317
+ } else {
318
+ if (pos >= peg$posDetailsCache.length) {
319
+ p = peg$posDetailsCache.length - 1;
320
+ } else {
321
+ p = pos;
322
+ while (!peg$posDetailsCache[--p]) {}
323
+ }
324
+
325
+ details = peg$posDetailsCache[p];
326
+ details = {
327
+ line: details.line,
328
+ column: details.column,
329
+ };
330
+
331
+ while (p < pos) {
332
+ if (input.charCodeAt(p) === 10) {
333
+ details.line++;
334
+ details.column = 1;
335
+ } else {
336
+ details.column++;
337
+ }
338
+
339
+ p++;
340
+ }
341
+
342
+ peg$posDetailsCache[pos] = details;
343
+
344
+ return details;
345
+ }
346
+ }
347
+
348
+ function peg$computeLocation(startPos, endPos, offset) {
349
+ const startPosDetails = peg$computePosDetails(startPos);
350
+ const endPosDetails = peg$computePosDetails(endPos);
351
+
352
+ const res = {
353
+ source: peg$source,
354
+ start: {
355
+ offset: startPos,
356
+ line: startPosDetails.line,
357
+ column: startPosDetails.column,
358
+ },
359
+ end: {
360
+ offset: endPos,
361
+ line: endPosDetails.line,
362
+ column: endPosDetails.column,
363
+ },
364
+ };
365
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
366
+ res.start = peg$source.offset(res.start);
367
+ res.end = peg$source.offset(res.end);
368
+ }
369
+ return res;
370
+ }
371
+
372
+ function peg$fail(expected) {
373
+ if (peg$currPos < peg$maxFailPos) { return; }
374
+
375
+ if (peg$currPos > peg$maxFailPos) {
376
+ peg$maxFailPos = peg$currPos;
377
+ peg$maxFailExpected = [];
378
+ }
379
+
380
+ peg$maxFailExpected.push(expected);
381
+ }
382
+
383
+ function peg$buildSimpleError(message, location) {
384
+ return new peg$SyntaxError(message, null, null, location);
385
+ }
386
+
387
+ function peg$buildStructuredError(expected, found, location) {
388
+ return new peg$SyntaxError(
389
+ peg$SyntaxError.buildMessage(expected, found),
390
+ expected,
391
+ found,
392
+ location
393
+ );
394
+ }
395
+
396
+ function peg$parsedocument() {
397
+ let s0, s1, s2, s3;
398
+
399
+ s0 = peg$currPos;
400
+ s1 = peg$parse_();
401
+ s2 = peg$parselinks();
402
+ if (s2 !== peg$FAILED) {
403
+ s3 = peg$parseeof();
404
+ if (s3 !== peg$FAILED) {
405
+ peg$savedPos = s0;
406
+ s0 = peg$f0(s2);
407
+ } else {
408
+ peg$currPos = s0;
409
+ s0 = peg$FAILED;
410
+ }
411
+ } else {
412
+ peg$currPos = s0;
413
+ s0 = peg$FAILED;
414
+ }
415
+ if (s0 === peg$FAILED) {
416
+ s0 = peg$currPos;
417
+ s1 = peg$parse_();
418
+ s2 = peg$parseeof();
419
+ if (s2 !== peg$FAILED) {
420
+ peg$savedPos = s0;
421
+ s0 = peg$f1();
422
+ } else {
423
+ peg$currPos = s0;
424
+ s0 = peg$FAILED;
425
+ }
426
+ }
427
+
428
+ return s0;
429
+ }
430
+
431
+ function peg$parselinks() {
432
+ let s0, s1, s2, s3;
433
+
434
+ s0 = peg$currPos;
435
+ s1 = peg$parsefirstLine();
436
+ if (s1 !== peg$FAILED) {
437
+ s2 = [];
438
+ s3 = peg$parseline();
439
+ while (s3 !== peg$FAILED) {
440
+ s2.push(s3);
441
+ s3 = peg$parseline();
442
+ }
443
+ peg$savedPos = s0;
444
+ s0 = peg$f2(s1, s2);
445
+ } else {
446
+ peg$currPos = s0;
447
+ s0 = peg$FAILED;
448
+ }
449
+
450
+ return s0;
451
+ }
452
+
453
+ function peg$parsefirstLine() {
454
+ let s0, s1;
455
+
456
+ s0 = peg$currPos;
457
+ s1 = peg$parseelement();
458
+ if (s1 !== peg$FAILED) {
459
+ peg$savedPos = s0;
460
+ s1 = peg$f3(s1);
461
+ }
462
+ s0 = s1;
463
+
464
+ return s0;
465
+ }
466
+
467
+ function peg$parseline() {
468
+ let s0, s1, s2;
469
+
470
+ s0 = peg$currPos;
471
+ s1 = peg$parseCHECK_INDENTATION();
472
+ if (s1 !== peg$FAILED) {
473
+ s2 = peg$parseelement();
474
+ if (s2 !== peg$FAILED) {
475
+ peg$savedPos = s0;
476
+ s0 = peg$f4(s2);
477
+ } else {
478
+ peg$currPos = s0;
479
+ s0 = peg$FAILED;
480
+ }
481
+ } else {
482
+ peg$currPos = s0;
483
+ s0 = peg$FAILED;
484
+ }
485
+
486
+ return s0;
487
+ }
488
+
489
+ function peg$parseelement() {
490
+ let s0, s1, s2, s3;
491
+
492
+ s0 = peg$currPos;
493
+ s1 = peg$parseanyLink();
494
+ if (s1 !== peg$FAILED) {
495
+ s2 = peg$parsePUSH_INDENTATION();
496
+ if (s2 !== peg$FAILED) {
497
+ s3 = peg$parselinks();
498
+ if (s3 !== peg$FAILED) {
499
+ peg$savedPos = s0;
500
+ s0 = peg$f5(s1, s3);
501
+ } else {
502
+ peg$currPos = s0;
503
+ s0 = peg$FAILED;
504
+ }
505
+ } else {
506
+ peg$currPos = s0;
507
+ s0 = peg$FAILED;
508
+ }
509
+ } else {
510
+ peg$currPos = s0;
511
+ s0 = peg$FAILED;
512
+ }
513
+ if (s0 === peg$FAILED) {
514
+ s0 = peg$currPos;
515
+ s1 = peg$parseanyLink();
516
+ if (s1 !== peg$FAILED) {
517
+ peg$savedPos = s0;
518
+ s1 = peg$f6(s1);
519
+ }
520
+ s0 = s1;
521
+ }
522
+
523
+ return s0;
524
+ }
525
+
526
+ function peg$parsereferenceOrLink() {
527
+ let s0, s1;
528
+
529
+ s0 = peg$currPos;
530
+ s1 = peg$parsemultiLineAnyLink();
531
+ if (s1 !== peg$FAILED) {
532
+ peg$savedPos = s0;
533
+ s1 = peg$f7(s1);
534
+ }
535
+ s0 = s1;
536
+ if (s0 === peg$FAILED) {
537
+ s0 = peg$currPos;
538
+ s1 = peg$parsereference();
539
+ if (s1 !== peg$FAILED) {
540
+ peg$savedPos = s0;
541
+ s1 = peg$f8(s1);
542
+ }
543
+ s0 = s1;
544
+ }
545
+
546
+ return s0;
547
+ }
548
+
549
+ function peg$parseanyLink() {
550
+ let s0, s1, s2;
551
+
552
+ s0 = peg$currPos;
553
+ s1 = peg$parsemultiLineAnyLink();
554
+ if (s1 !== peg$FAILED) {
555
+ s2 = peg$parseeol();
556
+ if (s2 !== peg$FAILED) {
557
+ peg$savedPos = s0;
558
+ s0 = peg$f9(s1);
559
+ } else {
560
+ peg$currPos = s0;
561
+ s0 = peg$FAILED;
562
+ }
563
+ } else {
564
+ peg$currPos = s0;
565
+ s0 = peg$FAILED;
566
+ }
567
+ if (s0 === peg$FAILED) {
568
+ s0 = peg$currPos;
569
+ s1 = peg$parseindentedIdLink();
570
+ if (s1 !== peg$FAILED) {
571
+ peg$savedPos = s0;
572
+ s1 = peg$f10(s1);
573
+ }
574
+ s0 = s1;
575
+ if (s0 === peg$FAILED) {
576
+ s0 = peg$currPos;
577
+ s1 = peg$parsesingleLineAnyLink();
578
+ if (s1 !== peg$FAILED) {
579
+ peg$savedPos = s0;
580
+ s1 = peg$f11(s1);
581
+ }
582
+ s0 = s1;
583
+ }
584
+ }
585
+
586
+ return s0;
587
+ }
588
+
589
+ function peg$parsemultiLineAnyLink() {
590
+ let s0;
591
+
592
+ s0 = peg$parsemultiLineValueLink();
593
+ if (s0 === peg$FAILED) {
594
+ s0 = peg$parsemultiLineLink();
595
+ }
596
+
597
+ return s0;
598
+ }
599
+
600
+ function peg$parsesingleLineAnyLink() {
601
+ let s0, s1, s2;
602
+
603
+ s0 = peg$currPos;
604
+ s1 = peg$parsesingleLineLink();
605
+ if (s1 !== peg$FAILED) {
606
+ s2 = peg$parseeol();
607
+ if (s2 !== peg$FAILED) {
608
+ peg$savedPos = s0;
609
+ s0 = peg$f12(s1);
610
+ } else {
611
+ peg$currPos = s0;
612
+ s0 = peg$FAILED;
613
+ }
614
+ } else {
615
+ peg$currPos = s0;
616
+ s0 = peg$FAILED;
617
+ }
618
+ if (s0 === peg$FAILED) {
619
+ s0 = peg$currPos;
620
+ s1 = peg$parsesingleLineValueLink();
621
+ if (s1 !== peg$FAILED) {
622
+ s2 = peg$parseeol();
623
+ if (s2 !== peg$FAILED) {
624
+ peg$savedPos = s0;
625
+ s0 = peg$f13(s1);
626
+ } else {
627
+ peg$currPos = s0;
628
+ s0 = peg$FAILED;
629
+ }
630
+ } else {
631
+ peg$currPos = s0;
632
+ s0 = peg$FAILED;
633
+ }
634
+ }
635
+
636
+ return s0;
637
+ }
638
+
639
+ function peg$parsemultiLineValueAndWhitespace() {
640
+ let s0, s1, s2;
641
+
642
+ s0 = peg$currPos;
643
+ s1 = peg$parsereferenceOrLink();
644
+ if (s1 !== peg$FAILED) {
645
+ s2 = peg$parse_();
646
+ peg$savedPos = s0;
647
+ s0 = peg$f14(s1);
648
+ } else {
649
+ peg$currPos = s0;
650
+ s0 = peg$FAILED;
651
+ }
652
+
653
+ return s0;
654
+ }
655
+
656
+ function peg$parsemultiLineValues() {
657
+ let s0, s1, s2, s3;
658
+
659
+ s0 = peg$currPos;
660
+ s1 = peg$parse_();
661
+ s2 = [];
662
+ s3 = peg$parsemultiLineValueAndWhitespace();
663
+ while (s3 !== peg$FAILED) {
664
+ s2.push(s3);
665
+ s3 = peg$parsemultiLineValueAndWhitespace();
666
+ }
667
+ peg$savedPos = s0;
668
+ s0 = peg$f15(s2);
669
+
670
+ return s0;
671
+ }
672
+
673
+ function peg$parsesingleLineValueAndWhitespace() {
674
+ let s0, s1, s2;
675
+
676
+ s0 = peg$currPos;
677
+ s1 = peg$parse__();
678
+ s2 = peg$parsereferenceOrLink();
679
+ if (s2 !== peg$FAILED) {
680
+ peg$savedPos = s0;
681
+ s0 = peg$f16(s2);
682
+ } else {
683
+ peg$currPos = s0;
684
+ s0 = peg$FAILED;
685
+ }
686
+
687
+ return s0;
688
+ }
689
+
690
+ function peg$parsesingleLineValues() {
691
+ let s0, s1, s2;
692
+
693
+ s0 = peg$currPos;
694
+ s1 = [];
695
+ s2 = peg$parsesingleLineValueAndWhitespace();
696
+ if (s2 !== peg$FAILED) {
697
+ while (s2 !== peg$FAILED) {
698
+ s1.push(s2);
699
+ s2 = peg$parsesingleLineValueAndWhitespace();
700
+ }
701
+ } else {
702
+ s1 = peg$FAILED;
703
+ }
704
+ if (s1 !== peg$FAILED) {
705
+ peg$savedPos = s0;
706
+ s1 = peg$f17(s1);
707
+ }
708
+ s0 = s1;
709
+
710
+ return s0;
711
+ }
712
+
713
+ function peg$parsesingleLineLink() {
714
+ let s0, s1, s2, s3, s4, s5;
715
+
716
+ s0 = peg$currPos;
717
+ s1 = peg$parse__();
718
+ s2 = peg$parsereference();
719
+ if (s2 !== peg$FAILED) {
720
+ s3 = peg$parse__();
721
+ if (input.charCodeAt(peg$currPos) === 58) {
722
+ s4 = peg$c0;
723
+ peg$currPos++;
724
+ } else {
725
+ s4 = peg$FAILED;
726
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
727
+ }
728
+ if (s4 !== peg$FAILED) {
729
+ s5 = peg$parsesingleLineValues();
730
+ if (s5 !== peg$FAILED) {
731
+ peg$savedPos = s0;
732
+ s0 = peg$f18(s2, s5);
733
+ } else {
734
+ peg$currPos = s0;
735
+ s0 = peg$FAILED;
736
+ }
737
+ } else {
738
+ peg$currPos = s0;
739
+ s0 = peg$FAILED;
740
+ }
741
+ } else {
742
+ peg$currPos = s0;
743
+ s0 = peg$FAILED;
744
+ }
745
+
746
+ return s0;
747
+ }
748
+
749
+ function peg$parsemultiLineLink() {
750
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8;
751
+
752
+ s0 = peg$currPos;
753
+ if (input.charCodeAt(peg$currPos) === 40) {
754
+ s1 = peg$c1;
755
+ peg$currPos++;
756
+ } else {
757
+ s1 = peg$FAILED;
758
+ if (peg$silentFails === 0) { peg$fail(peg$e1); }
759
+ }
760
+ if (s1 !== peg$FAILED) {
761
+ s2 = peg$parse_();
762
+ s3 = peg$parsereference();
763
+ if (s3 !== peg$FAILED) {
764
+ s4 = peg$parse_();
765
+ if (input.charCodeAt(peg$currPos) === 58) {
766
+ s5 = peg$c0;
767
+ peg$currPos++;
768
+ } else {
769
+ s5 = peg$FAILED;
770
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
771
+ }
772
+ if (s5 !== peg$FAILED) {
773
+ s6 = peg$parsemultiLineValues();
774
+ s7 = peg$parse_();
775
+ if (input.charCodeAt(peg$currPos) === 41) {
776
+ s8 = peg$c2;
777
+ peg$currPos++;
778
+ } else {
779
+ s8 = peg$FAILED;
780
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
781
+ }
782
+ if (s8 !== peg$FAILED) {
783
+ peg$savedPos = s0;
784
+ s0 = peg$f19(s3, s6);
785
+ } else {
786
+ peg$currPos = s0;
787
+ s0 = peg$FAILED;
788
+ }
789
+ } else {
790
+ peg$currPos = s0;
791
+ s0 = peg$FAILED;
792
+ }
793
+ } else {
794
+ peg$currPos = s0;
795
+ s0 = peg$FAILED;
796
+ }
797
+ } else {
798
+ peg$currPos = s0;
799
+ s0 = peg$FAILED;
800
+ }
801
+
802
+ return s0;
803
+ }
804
+
805
+ function peg$parsesingleLineValueLink() {
806
+ let s0, s1;
807
+
808
+ s0 = peg$currPos;
809
+ s1 = peg$parsesingleLineValues();
810
+ if (s1 !== peg$FAILED) {
811
+ peg$savedPos = s0;
812
+ s1 = peg$f20(s1);
813
+ }
814
+ s0 = s1;
815
+
816
+ return s0;
817
+ }
818
+
819
+ function peg$parsemultiLineValueLink() {
820
+ let s0, s1, s2, s3, s4;
821
+
822
+ s0 = peg$currPos;
823
+ if (input.charCodeAt(peg$currPos) === 40) {
824
+ s1 = peg$c1;
825
+ peg$currPos++;
826
+ } else {
827
+ s1 = peg$FAILED;
828
+ if (peg$silentFails === 0) { peg$fail(peg$e1); }
829
+ }
830
+ if (s1 !== peg$FAILED) {
831
+ s2 = peg$parsemultiLineValues();
832
+ s3 = peg$parse_();
833
+ if (input.charCodeAt(peg$currPos) === 41) {
834
+ s4 = peg$c2;
835
+ peg$currPos++;
836
+ } else {
837
+ s4 = peg$FAILED;
838
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
839
+ }
840
+ if (s4 !== peg$FAILED) {
841
+ peg$savedPos = s0;
842
+ s0 = peg$f21(s2);
843
+ } else {
844
+ peg$currPos = s0;
845
+ s0 = peg$FAILED;
846
+ }
847
+ } else {
848
+ peg$currPos = s0;
849
+ s0 = peg$FAILED;
850
+ }
851
+
852
+ return s0;
853
+ }
854
+
855
+ function peg$parseindentedIdLink() {
856
+ let s0, s1, s2, s3, s4;
857
+
858
+ s0 = peg$currPos;
859
+ s1 = peg$parsereference();
860
+ if (s1 !== peg$FAILED) {
861
+ s2 = peg$parse__();
862
+ if (input.charCodeAt(peg$currPos) === 58) {
863
+ s3 = peg$c0;
864
+ peg$currPos++;
865
+ } else {
866
+ s3 = peg$FAILED;
867
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
868
+ }
869
+ if (s3 !== peg$FAILED) {
870
+ s4 = peg$parseeol();
871
+ if (s4 !== peg$FAILED) {
872
+ peg$savedPos = s0;
873
+ s0 = peg$f22(s1);
874
+ } else {
875
+ peg$currPos = s0;
876
+ s0 = peg$FAILED;
877
+ }
878
+ } else {
879
+ peg$currPos = s0;
880
+ s0 = peg$FAILED;
881
+ }
882
+ } else {
883
+ peg$currPos = s0;
884
+ s0 = peg$FAILED;
885
+ }
886
+
887
+ return s0;
888
+ }
889
+
890
+ function peg$parsereference() {
891
+ let s0;
892
+
893
+ s0 = peg$parsedoubleQuotedReference();
894
+ if (s0 === peg$FAILED) {
895
+ s0 = peg$parsesingleQuotedReference();
896
+ if (s0 === peg$FAILED) {
897
+ s0 = peg$parsesimpleReference();
898
+ }
899
+ }
900
+
901
+ return s0;
902
+ }
903
+
904
+ function peg$parsesimpleReference() {
905
+ let s0, s1, s2;
906
+
907
+ s0 = peg$currPos;
908
+ s1 = [];
909
+ s2 = peg$parsereferenceSymbol();
910
+ if (s2 !== peg$FAILED) {
911
+ while (s2 !== peg$FAILED) {
912
+ s1.push(s2);
913
+ s2 = peg$parsereferenceSymbol();
914
+ }
915
+ } else {
916
+ s1 = peg$FAILED;
917
+ }
918
+ if (s1 !== peg$FAILED) {
919
+ peg$savedPos = s0;
920
+ s1 = peg$f23(s1);
921
+ }
922
+ s0 = s1;
923
+
924
+ return s0;
925
+ }
926
+
927
+ function peg$parsedoubleQuotedReference() {
928
+ let s0, s1, s2, s3;
929
+
930
+ s0 = peg$currPos;
931
+ if (input.charCodeAt(peg$currPos) === 34) {
932
+ s1 = peg$c3;
933
+ peg$currPos++;
934
+ } else {
935
+ s1 = peg$FAILED;
936
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
937
+ }
938
+ if (s1 !== peg$FAILED) {
939
+ s2 = [];
940
+ s3 = input.charAt(peg$currPos);
941
+ if (peg$r0.test(s3)) {
942
+ peg$currPos++;
943
+ } else {
944
+ s3 = peg$FAILED;
945
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
946
+ }
947
+ if (s3 !== peg$FAILED) {
948
+ while (s3 !== peg$FAILED) {
949
+ s2.push(s3);
950
+ s3 = input.charAt(peg$currPos);
951
+ if (peg$r0.test(s3)) {
952
+ peg$currPos++;
953
+ } else {
954
+ s3 = peg$FAILED;
955
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
956
+ }
957
+ }
958
+ } else {
959
+ s2 = peg$FAILED;
960
+ }
961
+ if (s2 !== peg$FAILED) {
962
+ if (input.charCodeAt(peg$currPos) === 34) {
963
+ s3 = peg$c3;
964
+ peg$currPos++;
965
+ } else {
966
+ s3 = peg$FAILED;
967
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
968
+ }
969
+ if (s3 !== peg$FAILED) {
970
+ peg$savedPos = s0;
971
+ s0 = peg$f24(s2);
972
+ } else {
973
+ peg$currPos = s0;
974
+ s0 = peg$FAILED;
975
+ }
976
+ } else {
977
+ peg$currPos = s0;
978
+ s0 = peg$FAILED;
979
+ }
980
+ } else {
981
+ peg$currPos = s0;
982
+ s0 = peg$FAILED;
983
+ }
984
+
985
+ return s0;
986
+ }
987
+
988
+ function peg$parsesingleQuotedReference() {
989
+ let s0, s1, s2, s3;
990
+
991
+ s0 = peg$currPos;
992
+ if (input.charCodeAt(peg$currPos) === 39) {
993
+ s1 = peg$c4;
994
+ peg$currPos++;
995
+ } else {
996
+ s1 = peg$FAILED;
997
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
998
+ }
999
+ if (s1 !== peg$FAILED) {
1000
+ s2 = [];
1001
+ s3 = input.charAt(peg$currPos);
1002
+ if (peg$r1.test(s3)) {
1003
+ peg$currPos++;
1004
+ } else {
1005
+ s3 = peg$FAILED;
1006
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1007
+ }
1008
+ if (s3 !== peg$FAILED) {
1009
+ while (s3 !== peg$FAILED) {
1010
+ s2.push(s3);
1011
+ s3 = input.charAt(peg$currPos);
1012
+ if (peg$r1.test(s3)) {
1013
+ peg$currPos++;
1014
+ } else {
1015
+ s3 = peg$FAILED;
1016
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1017
+ }
1018
+ }
1019
+ } else {
1020
+ s2 = peg$FAILED;
1021
+ }
1022
+ if (s2 !== peg$FAILED) {
1023
+ if (input.charCodeAt(peg$currPos) === 39) {
1024
+ s3 = peg$c4;
1025
+ peg$currPos++;
1026
+ } else {
1027
+ s3 = peg$FAILED;
1028
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
1029
+ }
1030
+ if (s3 !== peg$FAILED) {
1031
+ peg$savedPos = s0;
1032
+ s0 = peg$f25(s2);
1033
+ } else {
1034
+ peg$currPos = s0;
1035
+ s0 = peg$FAILED;
1036
+ }
1037
+ } else {
1038
+ peg$currPos = s0;
1039
+ s0 = peg$FAILED;
1040
+ }
1041
+ } else {
1042
+ peg$currPos = s0;
1043
+ s0 = peg$FAILED;
1044
+ }
1045
+
1046
+ return s0;
1047
+ }
1048
+
1049
+ function peg$parsePUSH_INDENTATION() {
1050
+ let s0, s1, s2;
1051
+
1052
+ s0 = peg$currPos;
1053
+ s1 = [];
1054
+ if (input.charCodeAt(peg$currPos) === 32) {
1055
+ s2 = peg$c5;
1056
+ peg$currPos++;
1057
+ } else {
1058
+ s2 = peg$FAILED;
1059
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
1060
+ }
1061
+ while (s2 !== peg$FAILED) {
1062
+ s1.push(s2);
1063
+ if (input.charCodeAt(peg$currPos) === 32) {
1064
+ s2 = peg$c5;
1065
+ peg$currPos++;
1066
+ } else {
1067
+ s2 = peg$FAILED;
1068
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
1069
+ }
1070
+ }
1071
+ peg$savedPos = peg$currPos;
1072
+ s2 = peg$f26(s1);
1073
+ if (s2) {
1074
+ s2 = undefined;
1075
+ } else {
1076
+ s2 = peg$FAILED;
1077
+ }
1078
+ if (s2 !== peg$FAILED) {
1079
+ peg$savedPos = s0;
1080
+ s0 = peg$f27(s1);
1081
+ } else {
1082
+ peg$currPos = s0;
1083
+ s0 = peg$FAILED;
1084
+ }
1085
+
1086
+ return s0;
1087
+ }
1088
+
1089
+ function peg$parseCHECK_INDENTATION() {
1090
+ let s0, s1, s2;
1091
+
1092
+ s0 = peg$currPos;
1093
+ s1 = [];
1094
+ if (input.charCodeAt(peg$currPos) === 32) {
1095
+ s2 = peg$c5;
1096
+ peg$currPos++;
1097
+ } else {
1098
+ s2 = peg$FAILED;
1099
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
1100
+ }
1101
+ while (s2 !== peg$FAILED) {
1102
+ s1.push(s2);
1103
+ if (input.charCodeAt(peg$currPos) === 32) {
1104
+ s2 = peg$c5;
1105
+ peg$currPos++;
1106
+ } else {
1107
+ s2 = peg$FAILED;
1108
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
1109
+ }
1110
+ }
1111
+ peg$savedPos = peg$currPos;
1112
+ s2 = peg$f28(s1);
1113
+ if (s2) {
1114
+ s2 = undefined;
1115
+ } else {
1116
+ s2 = peg$FAILED;
1117
+ }
1118
+ if (s2 !== peg$FAILED) {
1119
+ s1 = [s1, s2];
1120
+ s0 = s1;
1121
+ } else {
1122
+ peg$currPos = s0;
1123
+ s0 = peg$FAILED;
1124
+ }
1125
+
1126
+ return s0;
1127
+ }
1128
+
1129
+ function peg$parseeol() {
1130
+ let s0, s1, s2, s3;
1131
+
1132
+ s0 = peg$currPos;
1133
+ s1 = peg$parse__();
1134
+ s2 = [];
1135
+ s3 = input.charAt(peg$currPos);
1136
+ if (peg$r2.test(s3)) {
1137
+ peg$currPos++;
1138
+ } else {
1139
+ s3 = peg$FAILED;
1140
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
1141
+ }
1142
+ if (s3 !== peg$FAILED) {
1143
+ while (s3 !== peg$FAILED) {
1144
+ s2.push(s3);
1145
+ s3 = input.charAt(peg$currPos);
1146
+ if (peg$r2.test(s3)) {
1147
+ peg$currPos++;
1148
+ } else {
1149
+ s3 = peg$FAILED;
1150
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
1151
+ }
1152
+ }
1153
+ } else {
1154
+ s2 = peg$FAILED;
1155
+ }
1156
+ if (s2 === peg$FAILED) {
1157
+ s2 = peg$parseeof();
1158
+ }
1159
+ if (s2 !== peg$FAILED) {
1160
+ s1 = [s1, s2];
1161
+ s0 = s1;
1162
+ } else {
1163
+ peg$currPos = s0;
1164
+ s0 = peg$FAILED;
1165
+ }
1166
+
1167
+ return s0;
1168
+ }
1169
+
1170
+ function peg$parseeof() {
1171
+ let s0, s1;
1172
+
1173
+ s0 = peg$currPos;
1174
+ peg$silentFails++;
1175
+ if (input.length > peg$currPos) {
1176
+ s1 = input.charAt(peg$currPos);
1177
+ peg$currPos++;
1178
+ } else {
1179
+ s1 = peg$FAILED;
1180
+ if (peg$silentFails === 0) { peg$fail(peg$e9); }
1181
+ }
1182
+ peg$silentFails--;
1183
+ if (s1 === peg$FAILED) {
1184
+ s0 = undefined;
1185
+ } else {
1186
+ peg$currPos = s0;
1187
+ s0 = peg$FAILED;
1188
+ }
1189
+
1190
+ return s0;
1191
+ }
1192
+
1193
+ function peg$parse__() {
1194
+ let s0, s1;
1195
+
1196
+ s0 = [];
1197
+ s1 = input.charAt(peg$currPos);
1198
+ if (peg$r3.test(s1)) {
1199
+ peg$currPos++;
1200
+ } else {
1201
+ s1 = peg$FAILED;
1202
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
1203
+ }
1204
+ while (s1 !== peg$FAILED) {
1205
+ s0.push(s1);
1206
+ s1 = input.charAt(peg$currPos);
1207
+ if (peg$r3.test(s1)) {
1208
+ peg$currPos++;
1209
+ } else {
1210
+ s1 = peg$FAILED;
1211
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
1212
+ }
1213
+ }
1214
+
1215
+ return s0;
1216
+ }
1217
+
1218
+ function peg$parse_() {
1219
+ let s0, s1;
1220
+
1221
+ s0 = [];
1222
+ s1 = peg$parsewhiteSpaceSymbol();
1223
+ while (s1 !== peg$FAILED) {
1224
+ s0.push(s1);
1225
+ s1 = peg$parsewhiteSpaceSymbol();
1226
+ }
1227
+
1228
+ return s0;
1229
+ }
1230
+
1231
+ function peg$parsewhiteSpaceSymbol() {
1232
+ let s0;
1233
+
1234
+ s0 = input.charAt(peg$currPos);
1235
+ if (peg$r4.test(s0)) {
1236
+ peg$currPos++;
1237
+ } else {
1238
+ s0 = peg$FAILED;
1239
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
1240
+ }
1241
+
1242
+ return s0;
1243
+ }
1244
+
1245
+ function peg$parsereferenceSymbol() {
1246
+ let s0;
1247
+
1248
+ s0 = input.charAt(peg$currPos);
1249
+ if (peg$r5.test(s0)) {
1250
+ peg$currPos++;
1251
+ } else {
1252
+ s0 = peg$FAILED;
1253
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
1254
+ }
1255
+
1256
+ return s0;
1257
+ }
1258
+
1259
+
1260
+ let indentationStack = [0];
1261
+
1262
+ function pushIndentation(spaces) {
1263
+ indentationStack.push(spaces.length);
1264
+ }
1265
+
1266
+ function popIndentation() {
1267
+ if (indentationStack.length > 1) {
1268
+ indentationStack.pop();
1269
+ }
1270
+ }
1271
+
1272
+ function checkIndentation(spaces) {
1273
+ return spaces.length >= indentationStack[indentationStack.length - 1];
1274
+ }
1275
+
1276
+ function getCurrentIndentation() {
1277
+ return indentationStack[indentationStack.length - 1];
1278
+ }
1279
+
1280
+ peg$result = peg$startRuleFunction();
1281
+
1282
+ const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);
1283
+ function peg$throw() {
1284
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1285
+ peg$fail(peg$endExpectation());
1286
+ }
1287
+
1288
+ throw peg$buildStructuredError(
1289
+ peg$maxFailExpected,
1290
+ peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null,
1291
+ peg$maxFailPos < input.length
1292
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1293
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1294
+ );
1295
+ }
1296
+ if (options.peg$library) {
1297
+ return /** @type {any} */ ({
1298
+ peg$result,
1299
+ peg$currPos,
1300
+ peg$FAILED,
1301
+ peg$maxFailExpected,
1302
+ peg$maxFailPos,
1303
+ peg$success,
1304
+ peg$throw: peg$success ? undefined : peg$throw,
1305
+ });
1306
+ }
1307
+ if (peg$success) {
1308
+ return peg$result;
1309
+ } else {
1310
+ peg$throw();
1311
+ }
1312
+ }
1313
+
1314
+ const peg$allowedStartRules = [
1315
+ "document"
1316
+ ];
1317
+
1318
+ export {
1319
+ peg$allowedStartRules as StartRules,
1320
+ peg$SyntaxError as SyntaxError,
1321
+ peg$parse as parse
1322
+ };