links-notation 0.21.1 → 0.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +439 -225
- package/package.json +1 -1
- package/src/StreamParser.js +3 -2
- package/src/comments.js +6 -70
- package/src/grammar.pegjs +54 -76
- package/src/parser-generated.js +304 -186
- package/src/quotes.js +251 -0
- package/tests/Issue316QuoteRuns.test.js +163 -0
- package/tests/NestingDepth.test.js +124 -0
- package/tests/support/nestingDepthWorker.js +15 -0
package/dist/index.js
CHANGED
|
@@ -341,9 +341,146 @@ function windowAround(lineText, column) {
|
|
|
341
341
|
return [quoted, target - start + shift + 1];
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
// src/quotes.js
|
|
345
|
+
var QUOTES = ['"', "'", "`"];
|
|
346
|
+
|
|
347
|
+
class DelimitedReferences {
|
|
348
|
+
constructor(document) {
|
|
349
|
+
this.document = document;
|
|
350
|
+
this.runsByQuote = new Map;
|
|
351
|
+
this.readings = new Map;
|
|
352
|
+
}
|
|
353
|
+
readAt(start) {
|
|
354
|
+
if (!this.readings.has(start)) {
|
|
355
|
+
this.readings.set(start, this.#read(start));
|
|
356
|
+
}
|
|
357
|
+
return this.readings.get(start);
|
|
358
|
+
}
|
|
359
|
+
endAt(start) {
|
|
360
|
+
const reading = this.readAt(start);
|
|
361
|
+
return reading === null ? null : start + reading.length;
|
|
362
|
+
}
|
|
363
|
+
#read(start) {
|
|
364
|
+
const document = this.document;
|
|
365
|
+
const quote = document[start];
|
|
366
|
+
if (!QUOTES.includes(quote)) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
const runs = this.#runsOf(quote);
|
|
370
|
+
const opening = runs.indexOf(start);
|
|
371
|
+
const count = runs.end(opening) - start;
|
|
372
|
+
let closing = opening + 1;
|
|
373
|
+
while (closing < runs.count) {
|
|
374
|
+
const length = runs.lengths[closing];
|
|
375
|
+
if (length < count) {
|
|
376
|
+
closing = runs.nextLonger[closing];
|
|
377
|
+
} else if (Math.floor(length / count) % 2 === 1) {
|
|
378
|
+
break;
|
|
379
|
+
} else {
|
|
380
|
+
closing++;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const end = closing < runs.count ? runs.end(closing) : null;
|
|
384
|
+
return reading(document, start, quote, count, end);
|
|
385
|
+
}
|
|
386
|
+
#runsOf(quote) {
|
|
387
|
+
if (!this.runsByQuote.has(quote)) {
|
|
388
|
+
this.runsByQuote.set(quote, new DelimiterRuns(this.document, quote));
|
|
389
|
+
}
|
|
390
|
+
return this.runsByQuote.get(quote);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function reading(document, start, quote, count, end) {
|
|
394
|
+
const emptyReference = count % 2 === 0 ? { value: "", length: count } : null;
|
|
395
|
+
if (end === null) {
|
|
396
|
+
return emptyReference;
|
|
397
|
+
}
|
|
398
|
+
const parts = [];
|
|
399
|
+
let position = start + count;
|
|
400
|
+
let run = document.indexOf(quote, position);
|
|
401
|
+
while (run !== -1 && run < end) {
|
|
402
|
+
const length = runLength(document, run, quote);
|
|
403
|
+
const escaped = Math.floor(length / (2 * count)) * count;
|
|
404
|
+
const closes = run + length === end ? count : 0;
|
|
405
|
+
parts.push(document.slice(position, run));
|
|
406
|
+
parts.push(quote.repeat(length - escaped - closes));
|
|
407
|
+
position = run + length;
|
|
408
|
+
run = document.indexOf(quote, position);
|
|
409
|
+
}
|
|
410
|
+
const value = parts.join("");
|
|
411
|
+
if (emptyReference !== null && !isSubstantiveBody(value)) {
|
|
412
|
+
return emptyReference;
|
|
413
|
+
}
|
|
414
|
+
return { value, length: end - start };
|
|
415
|
+
}
|
|
416
|
+
function runLength(text, start, quote) {
|
|
417
|
+
let end = start;
|
|
418
|
+
while (end < text.length && text[end] === quote) {
|
|
419
|
+
end++;
|
|
420
|
+
}
|
|
421
|
+
return end - start;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
class DelimiterRuns {
|
|
425
|
+
constructor(document, quote) {
|
|
426
|
+
this.starts = [];
|
|
427
|
+
this.lengths = [];
|
|
428
|
+
let position = document.indexOf(quote);
|
|
429
|
+
while (position !== -1) {
|
|
430
|
+
const length = runLength(document, position, quote);
|
|
431
|
+
this.starts.push(position);
|
|
432
|
+
this.lengths.push(length);
|
|
433
|
+
position = document.indexOf(quote, position + length);
|
|
434
|
+
}
|
|
435
|
+
this.count = this.starts.length;
|
|
436
|
+
this.nextLonger = new Array(this.count);
|
|
437
|
+
const longer = [];
|
|
438
|
+
for (let run = this.count - 1;run >= 0; run--) {
|
|
439
|
+
while (longer.length > 0 && this.lengths[longer[longer.length - 1]] <= this.lengths[run]) {
|
|
440
|
+
longer.pop();
|
|
441
|
+
}
|
|
442
|
+
this.nextLonger[run] = longer.length > 0 ? longer[longer.length - 1] : this.count;
|
|
443
|
+
longer.push(run);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
end(run) {
|
|
447
|
+
return this.starts[run] + this.lengths[run];
|
|
448
|
+
}
|
|
449
|
+
indexOf(position) {
|
|
450
|
+
let low = 0;
|
|
451
|
+
let high = this.count - 1;
|
|
452
|
+
while (low < high) {
|
|
453
|
+
const middle = low + high + 1 >> 1;
|
|
454
|
+
if (this.starts[middle] <= position) {
|
|
455
|
+
low = middle;
|
|
456
|
+
} else {
|
|
457
|
+
high = middle - 1;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return low;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function isSubstantiveBody(content) {
|
|
464
|
+
let depth = 0;
|
|
465
|
+
let hasVisible = false;
|
|
466
|
+
for (const character of content) {
|
|
467
|
+
if (character === "(") {
|
|
468
|
+
depth++;
|
|
469
|
+
} else if (character === ")") {
|
|
470
|
+
depth--;
|
|
471
|
+
if (depth < 0) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (!/[ \t\n\r]/.test(character)) {
|
|
476
|
+
hasVisible = true;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return hasVisible && depth === 0;
|
|
480
|
+
}
|
|
481
|
+
|
|
344
482
|
// src/comments.js
|
|
345
483
|
var COMMENT = "#";
|
|
346
|
-
var QUOTES = ['"', "'", "`"];
|
|
347
484
|
var BEFORE_REFERENCE = [" ", "\t", `
|
|
348
485
|
`, "\r", "(", ":"];
|
|
349
486
|
var BEFORE_COMMENT = [" ", "\t", `
|
|
@@ -351,10 +488,11 @@ var BEFORE_COMMENT = [" ", "\t", `
|
|
|
351
488
|
function stripComments(document) {
|
|
352
489
|
let blanked = null;
|
|
353
490
|
let position = 0;
|
|
491
|
+
const references = new DelimitedReferences(document);
|
|
354
492
|
while (position < document.length) {
|
|
355
493
|
const character = document[position];
|
|
356
494
|
if (QUOTES.includes(character) && follows(document, position, BEFORE_REFERENCE)) {
|
|
357
|
-
const end =
|
|
495
|
+
const end = references.endAt(position);
|
|
358
496
|
position = end === null ? position + 1 : end;
|
|
359
497
|
continue;
|
|
360
498
|
}
|
|
@@ -374,59 +512,6 @@ function stripComments(document) {
|
|
|
374
512
|
function follows(document, position, allowed) {
|
|
375
513
|
return position === 0 || allowed.includes(document[position - 1]);
|
|
376
514
|
}
|
|
377
|
-
function quotedReferenceEnd(document, start) {
|
|
378
|
-
const quote = document[start];
|
|
379
|
-
if (!QUOTES.includes(quote)) {
|
|
380
|
-
return null;
|
|
381
|
-
}
|
|
382
|
-
let position = start;
|
|
383
|
-
while (position < document.length && document[position] === quote) {
|
|
384
|
-
position++;
|
|
385
|
-
}
|
|
386
|
-
const count = position - start;
|
|
387
|
-
const isEvenRun = count % 2 === 0;
|
|
388
|
-
const emptyReference = isEvenRun ? start + count : null;
|
|
389
|
-
const closing = quote.repeat(count);
|
|
390
|
-
const escape = quote.repeat(count * 2);
|
|
391
|
-
let content = "";
|
|
392
|
-
while (position < document.length) {
|
|
393
|
-
if (document.startsWith(escape, position)) {
|
|
394
|
-
content += closing;
|
|
395
|
-
position += escape.length;
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
if (document.startsWith(closing, position)) {
|
|
399
|
-
const afterClosing = position + count;
|
|
400
|
-
if (afterClosing >= document.length || document[afterClosing] !== quote) {
|
|
401
|
-
if (isEvenRun && !isSubstantiveBody(content)) {
|
|
402
|
-
return emptyReference;
|
|
403
|
-
}
|
|
404
|
-
return afterClosing;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
content += document[position];
|
|
408
|
-
position++;
|
|
409
|
-
}
|
|
410
|
-
return emptyReference;
|
|
411
|
-
}
|
|
412
|
-
function isSubstantiveBody(content) {
|
|
413
|
-
let depth = 0;
|
|
414
|
-
let hasVisible = false;
|
|
415
|
-
for (const character of content) {
|
|
416
|
-
if (character === "(") {
|
|
417
|
-
depth++;
|
|
418
|
-
} else if (character === ")") {
|
|
419
|
-
depth--;
|
|
420
|
-
if (depth < 0) {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (!/[ \t\n\r]/.test(character)) {
|
|
425
|
-
hasVisible = true;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return hasVisible && depth === 0;
|
|
429
|
-
}
|
|
430
515
|
|
|
431
516
|
// src/parser-generated.js
|
|
432
517
|
class peg$SyntaxError extends SyntaxError {
|
|
@@ -554,11 +639,11 @@ function peg$parse(input, options) {
|
|
|
554
639
|
const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
|
|
555
640
|
const peg$e1 = peg$classExpectation(["\r", `
|
|
556
641
|
`], false, false, false);
|
|
557
|
-
const peg$e2 = peg$
|
|
558
|
-
const peg$e3 = peg$literalExpectation("
|
|
559
|
-
const peg$e4 = peg$literalExpectation("
|
|
560
|
-
const peg$e5 = peg$literalExpectation(
|
|
561
|
-
const peg$e6 = peg$
|
|
642
|
+
const peg$e2 = peg$anyExpectation();
|
|
643
|
+
const peg$e3 = peg$literalExpectation("(", false);
|
|
644
|
+
const peg$e4 = peg$literalExpectation(")", false);
|
|
645
|
+
const peg$e5 = peg$literalExpectation(":", false);
|
|
646
|
+
const peg$e6 = peg$literalExpectation('"', false);
|
|
562
647
|
const peg$e7 = peg$literalExpectation("'", false);
|
|
563
648
|
const peg$e8 = peg$literalExpectation("`", false);
|
|
564
649
|
const peg$e9 = peg$literalExpectation(" ", false);
|
|
@@ -588,26 +673,31 @@ function peg$parse(input, options) {
|
|
|
588
673
|
function peg$f6(l) {
|
|
589
674
|
return l;
|
|
590
675
|
}
|
|
591
|
-
function peg$f7(
|
|
676
|
+
function peg$f7() {
|
|
677
|
+
return !unreadableLines.has(lineKey(offset()));
|
|
678
|
+
}
|
|
679
|
+
function peg$f8(e, saved, l) {
|
|
680
|
+
if (l === null) {
|
|
681
|
+
indentationStack = saved;
|
|
682
|
+
return e;
|
|
683
|
+
}
|
|
592
684
|
return Object.assign({}, e, { children: l });
|
|
593
685
|
}
|
|
594
|
-
function peg$
|
|
595
|
-
|
|
686
|
+
function peg$f9() {
|
|
687
|
+
unreadableLines.add(lineKey(offset()));
|
|
688
|
+
return false;
|
|
596
689
|
}
|
|
597
|
-
function peg$
|
|
690
|
+
function peg$f10(l) {
|
|
598
691
|
return l;
|
|
599
692
|
}
|
|
600
|
-
function peg$
|
|
693
|
+
function peg$f11(i) {
|
|
601
694
|
return { id: i };
|
|
602
695
|
}
|
|
603
|
-
function peg$
|
|
604
|
-
return
|
|
605
|
-
}
|
|
606
|
-
function peg$f12(il) {
|
|
607
|
-
return il;
|
|
696
|
+
function peg$f12(g, rest) {
|
|
697
|
+
return rest === null ? g : { values: [g].concat(rest) };
|
|
608
698
|
}
|
|
609
|
-
function peg$f13(
|
|
610
|
-
return
|
|
699
|
+
function peg$f13() {
|
|
700
|
+
return null;
|
|
611
701
|
}
|
|
612
702
|
function peg$f14(fl) {
|
|
613
703
|
return fl;
|
|
@@ -619,34 +709,38 @@ function peg$parse(input, options) {
|
|
|
619
709
|
exitNestedContext();
|
|
620
710
|
return body;
|
|
621
711
|
}
|
|
622
|
-
function peg$f17(
|
|
712
|
+
function peg$f17() {
|
|
713
|
+
exitNestedContext();
|
|
714
|
+
return false;
|
|
715
|
+
}
|
|
716
|
+
function peg$f18(l) {
|
|
623
717
|
return { nested: l };
|
|
624
718
|
}
|
|
625
|
-
function peg$
|
|
719
|
+
function peg$f19() {
|
|
626
720
|
return { nested: [] };
|
|
627
721
|
}
|
|
628
|
-
function peg$
|
|
722
|
+
function peg$f20() {
|
|
629
723
|
return enterNestedContext();
|
|
630
724
|
}
|
|
631
|
-
function peg$
|
|
725
|
+
function peg$f21(value) {
|
|
632
726
|
return value;
|
|
633
727
|
}
|
|
634
|
-
function peg$
|
|
728
|
+
function peg$f22(list) {
|
|
635
729
|
return list;
|
|
636
730
|
}
|
|
637
|
-
function peg$
|
|
731
|
+
function peg$f23(id, v) {
|
|
638
732
|
return { id, values: v };
|
|
639
733
|
}
|
|
640
|
-
function peg$
|
|
734
|
+
function peg$f24(v) {
|
|
641
735
|
return { values: v };
|
|
642
736
|
}
|
|
643
|
-
function peg$
|
|
737
|
+
function peg$f25(id) {
|
|
644
738
|
return { id, values: [] };
|
|
645
739
|
}
|
|
646
|
-
function peg$
|
|
740
|
+
function peg$f26(chars) {
|
|
647
741
|
return chars.join("");
|
|
648
742
|
}
|
|
649
|
-
function peg$
|
|
743
|
+
function peg$f27() {
|
|
650
744
|
const pos = offset();
|
|
651
745
|
const result = parseQuotedStringAt(input, pos, '"');
|
|
652
746
|
if (result) {
|
|
@@ -656,19 +750,19 @@ function peg$parse(input, options) {
|
|
|
656
750
|
}
|
|
657
751
|
return false;
|
|
658
752
|
}
|
|
659
|
-
function peg$
|
|
753
|
+
function peg$f28(chars) {
|
|
660
754
|
return parsedValue;
|
|
661
755
|
}
|
|
662
|
-
function peg$
|
|
756
|
+
function peg$f29(c, cs) {
|
|
663
757
|
return [c].concat(cs).join("");
|
|
664
758
|
}
|
|
665
|
-
function peg$
|
|
759
|
+
function peg$f30() {
|
|
666
760
|
return parsedLength > 1 && (parsedLength--, true);
|
|
667
761
|
}
|
|
668
|
-
function peg$
|
|
762
|
+
function peg$f31(c) {
|
|
669
763
|
return c;
|
|
670
764
|
}
|
|
671
|
-
function peg$
|
|
765
|
+
function peg$f32() {
|
|
672
766
|
const pos = offset();
|
|
673
767
|
const result = parseQuotedStringAt(input, pos, "'");
|
|
674
768
|
if (result) {
|
|
@@ -678,19 +772,19 @@ function peg$parse(input, options) {
|
|
|
678
772
|
}
|
|
679
773
|
return false;
|
|
680
774
|
}
|
|
681
|
-
function peg$
|
|
775
|
+
function peg$f33(chars) {
|
|
682
776
|
return parsedValue;
|
|
683
777
|
}
|
|
684
|
-
function peg$
|
|
778
|
+
function peg$f34(c, cs) {
|
|
685
779
|
return [c].concat(cs).join("");
|
|
686
780
|
}
|
|
687
|
-
function peg$
|
|
781
|
+
function peg$f35() {
|
|
688
782
|
return parsedLength > 1 && (parsedLength--, true);
|
|
689
783
|
}
|
|
690
|
-
function peg$
|
|
784
|
+
function peg$f36(c) {
|
|
691
785
|
return c;
|
|
692
786
|
}
|
|
693
|
-
function peg$
|
|
787
|
+
function peg$f37() {
|
|
694
788
|
const pos = offset();
|
|
695
789
|
const result = parseQuotedStringAt(input, pos, "`");
|
|
696
790
|
if (result) {
|
|
@@ -700,31 +794,34 @@ function peg$parse(input, options) {
|
|
|
700
794
|
}
|
|
701
795
|
return false;
|
|
702
796
|
}
|
|
703
|
-
function peg$
|
|
797
|
+
function peg$f38(chars) {
|
|
704
798
|
return parsedValue;
|
|
705
799
|
}
|
|
706
|
-
function peg$
|
|
800
|
+
function peg$f39(c, cs) {
|
|
707
801
|
return [c].concat(cs).join("");
|
|
708
802
|
}
|
|
709
|
-
function peg$
|
|
803
|
+
function peg$f40() {
|
|
710
804
|
return parsedLength > 1 && (parsedLength--, true);
|
|
711
805
|
}
|
|
712
|
-
function peg$
|
|
806
|
+
function peg$f41(c) {
|
|
713
807
|
return c;
|
|
714
808
|
}
|
|
715
|
-
function peg$
|
|
809
|
+
function peg$f42() {
|
|
810
|
+
return indentationStack.slice();
|
|
811
|
+
}
|
|
812
|
+
function peg$f43(spaces) {
|
|
716
813
|
setBaseIndentation(spaces);
|
|
717
814
|
}
|
|
718
|
-
function peg$
|
|
815
|
+
function peg$f44(spaces) {
|
|
719
816
|
return normalizeIndentation(spaces) > getCurrentIndentation();
|
|
720
817
|
}
|
|
721
|
-
function peg$
|
|
818
|
+
function peg$f45(spaces) {
|
|
722
819
|
pushIndentation(spaces);
|
|
723
820
|
}
|
|
724
|
-
function peg$
|
|
821
|
+
function peg$f46(spaces) {
|
|
725
822
|
return checkIndentation(spaces);
|
|
726
823
|
}
|
|
727
|
-
function peg$
|
|
824
|
+
function peg$f47() {
|
|
728
825
|
return isInsideNestedContext();
|
|
729
826
|
}
|
|
730
827
|
let peg$currPos = options.peg$currPos | 0;
|
|
@@ -1050,20 +1147,38 @@ function peg$parse(input, options) {
|
|
|
1050
1147
|
return s0;
|
|
1051
1148
|
}
|
|
1052
1149
|
function peg$parseelement() {
|
|
1053
|
-
let s0, s1, s2, s3;
|
|
1150
|
+
let s0, s1, s2, s3, s4, s5, s6;
|
|
1054
1151
|
s0 = peg$currPos;
|
|
1055
|
-
|
|
1152
|
+
peg$savedPos = peg$currPos;
|
|
1153
|
+
s1 = peg$f7();
|
|
1154
|
+
if (s1) {
|
|
1155
|
+
s1 = undefined;
|
|
1156
|
+
} else {
|
|
1157
|
+
s1 = peg$FAILED;
|
|
1158
|
+
}
|
|
1056
1159
|
if (s1 !== peg$FAILED) {
|
|
1057
|
-
s2 = peg$
|
|
1160
|
+
s2 = peg$parseanyLink();
|
|
1058
1161
|
if (s2 !== peg$FAILED) {
|
|
1059
|
-
s3 = peg$
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1162
|
+
s3 = peg$parseSAVE_INDENTATION();
|
|
1163
|
+
s4 = peg$currPos;
|
|
1164
|
+
s5 = peg$parsePUSH_INDENTATION();
|
|
1165
|
+
if (s5 !== peg$FAILED) {
|
|
1166
|
+
s6 = peg$parselinks();
|
|
1167
|
+
if (s6 !== peg$FAILED) {
|
|
1168
|
+
s4 = s6;
|
|
1169
|
+
} else {
|
|
1170
|
+
peg$currPos = s4;
|
|
1171
|
+
s4 = peg$FAILED;
|
|
1172
|
+
}
|
|
1063
1173
|
} else {
|
|
1064
|
-
peg$currPos =
|
|
1065
|
-
|
|
1174
|
+
peg$currPos = s4;
|
|
1175
|
+
s4 = peg$FAILED;
|
|
1176
|
+
}
|
|
1177
|
+
if (s4 === peg$FAILED) {
|
|
1178
|
+
s4 = null;
|
|
1066
1179
|
}
|
|
1180
|
+
peg$savedPos = s0;
|
|
1181
|
+
s0 = peg$f8(s2, s3, s4);
|
|
1067
1182
|
} else {
|
|
1068
1183
|
peg$currPos = s0;
|
|
1069
1184
|
s0 = peg$FAILED;
|
|
@@ -1074,12 +1189,34 @@ function peg$parse(input, options) {
|
|
|
1074
1189
|
}
|
|
1075
1190
|
if (s0 === peg$FAILED) {
|
|
1076
1191
|
s0 = peg$currPos;
|
|
1077
|
-
|
|
1192
|
+
peg$savedPos = peg$currPos;
|
|
1193
|
+
s1 = peg$f9();
|
|
1194
|
+
if (s1) {
|
|
1195
|
+
s1 = undefined;
|
|
1196
|
+
} else {
|
|
1197
|
+
s1 = peg$FAILED;
|
|
1198
|
+
}
|
|
1078
1199
|
if (s1 !== peg$FAILED) {
|
|
1079
|
-
peg$
|
|
1080
|
-
|
|
1200
|
+
if (input.length > peg$currPos) {
|
|
1201
|
+
s2 = input.charAt(peg$currPos);
|
|
1202
|
+
peg$currPos++;
|
|
1203
|
+
} else {
|
|
1204
|
+
s2 = peg$FAILED;
|
|
1205
|
+
if (peg$silentFails === 0) {
|
|
1206
|
+
peg$fail(peg$e2);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
if (s2 !== peg$FAILED) {
|
|
1210
|
+
s1 = [s1, s2];
|
|
1211
|
+
s0 = s1;
|
|
1212
|
+
} else {
|
|
1213
|
+
peg$currPos = s0;
|
|
1214
|
+
s0 = peg$FAILED;
|
|
1215
|
+
}
|
|
1216
|
+
} else {
|
|
1217
|
+
peg$currPos = s0;
|
|
1218
|
+
s0 = peg$FAILED;
|
|
1081
1219
|
}
|
|
1082
|
-
s0 = s1;
|
|
1083
1220
|
}
|
|
1084
1221
|
return s0;
|
|
1085
1222
|
}
|
|
@@ -1089,7 +1226,7 @@ function peg$parse(input, options) {
|
|
|
1089
1226
|
s1 = peg$parsenestedGroup();
|
|
1090
1227
|
if (s1 !== peg$FAILED) {
|
|
1091
1228
|
peg$savedPos = s0;
|
|
1092
|
-
s1 = peg$
|
|
1229
|
+
s1 = peg$f10(s1);
|
|
1093
1230
|
}
|
|
1094
1231
|
s0 = s1;
|
|
1095
1232
|
if (s0 === peg$FAILED) {
|
|
@@ -1097,7 +1234,7 @@ function peg$parse(input, options) {
|
|
|
1097
1234
|
s1 = peg$parsereference();
|
|
1098
1235
|
if (s1 !== peg$FAILED) {
|
|
1099
1236
|
peg$savedPos = s0;
|
|
1100
|
-
s1 = peg$
|
|
1237
|
+
s1 = peg$f11(s1);
|
|
1101
1238
|
}
|
|
1102
1239
|
s0 = s1;
|
|
1103
1240
|
}
|
|
@@ -1106,12 +1243,28 @@ function peg$parse(input, options) {
|
|
|
1106
1243
|
function peg$parseanyLink() {
|
|
1107
1244
|
let s0, s1, s2;
|
|
1108
1245
|
s0 = peg$currPos;
|
|
1109
|
-
s1 = peg$
|
|
1246
|
+
s1 = peg$currPos;
|
|
1247
|
+
peg$silentFails++;
|
|
1248
|
+
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1249
|
+
s2 = peg$c0;
|
|
1250
|
+
peg$currPos++;
|
|
1251
|
+
} else {
|
|
1252
|
+
s2 = peg$FAILED;
|
|
1253
|
+
if (peg$silentFails === 0) {
|
|
1254
|
+
peg$fail(peg$e3);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
peg$silentFails--;
|
|
1258
|
+
if (s2 !== peg$FAILED) {
|
|
1259
|
+
peg$currPos = s1;
|
|
1260
|
+
s1 = undefined;
|
|
1261
|
+
} else {
|
|
1262
|
+
s1 = peg$FAILED;
|
|
1263
|
+
}
|
|
1110
1264
|
if (s1 !== peg$FAILED) {
|
|
1111
|
-
s2 = peg$
|
|
1265
|
+
s2 = peg$parsegroupLink();
|
|
1112
1266
|
if (s2 !== peg$FAILED) {
|
|
1113
|
-
|
|
1114
|
-
s0 = peg$f11(s1);
|
|
1267
|
+
s0 = s2;
|
|
1115
1268
|
} else {
|
|
1116
1269
|
peg$currPos = s0;
|
|
1117
1270
|
s0 = peg$FAILED;
|
|
@@ -1122,20 +1275,84 @@ function peg$parse(input, options) {
|
|
|
1122
1275
|
}
|
|
1123
1276
|
if (s0 === peg$FAILED) {
|
|
1124
1277
|
s0 = peg$currPos;
|
|
1125
|
-
s1 = peg$
|
|
1278
|
+
s1 = peg$currPos;
|
|
1279
|
+
peg$silentFails++;
|
|
1280
|
+
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1281
|
+
s2 = peg$c0;
|
|
1282
|
+
peg$currPos++;
|
|
1283
|
+
} else {
|
|
1284
|
+
s2 = peg$FAILED;
|
|
1285
|
+
if (peg$silentFails === 0) {
|
|
1286
|
+
peg$fail(peg$e3);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
peg$silentFails--;
|
|
1290
|
+
if (s2 === peg$FAILED) {
|
|
1291
|
+
s1 = undefined;
|
|
1292
|
+
} else {
|
|
1293
|
+
peg$currPos = s1;
|
|
1294
|
+
s1 = peg$FAILED;
|
|
1295
|
+
}
|
|
1126
1296
|
if (s1 !== peg$FAILED) {
|
|
1297
|
+
s2 = peg$parseindentedIdLink();
|
|
1298
|
+
if (s2 === peg$FAILED) {
|
|
1299
|
+
s2 = peg$parsesingleLineAnyLink();
|
|
1300
|
+
}
|
|
1301
|
+
if (s2 !== peg$FAILED) {
|
|
1302
|
+
s0 = s2;
|
|
1303
|
+
} else {
|
|
1304
|
+
peg$currPos = s0;
|
|
1305
|
+
s0 = peg$FAILED;
|
|
1306
|
+
}
|
|
1307
|
+
} else {
|
|
1308
|
+
peg$currPos = s0;
|
|
1309
|
+
s0 = peg$FAILED;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return s0;
|
|
1313
|
+
}
|
|
1314
|
+
function peg$parsegroupLink() {
|
|
1315
|
+
let s0, s1, s2;
|
|
1316
|
+
s0 = peg$currPos;
|
|
1317
|
+
s1 = peg$parsenestedGroup();
|
|
1318
|
+
if (s1 !== peg$FAILED) {
|
|
1319
|
+
s2 = peg$parsegroupLinkRest();
|
|
1320
|
+
if (s2 !== peg$FAILED) {
|
|
1127
1321
|
peg$savedPos = s0;
|
|
1128
|
-
|
|
1322
|
+
s0 = peg$f12(s1, s2);
|
|
1323
|
+
} else {
|
|
1324
|
+
peg$currPos = s0;
|
|
1325
|
+
s0 = peg$FAILED;
|
|
1129
1326
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1327
|
+
} else {
|
|
1328
|
+
peg$currPos = s0;
|
|
1329
|
+
s0 = peg$FAILED;
|
|
1330
|
+
}
|
|
1331
|
+
return s0;
|
|
1332
|
+
}
|
|
1333
|
+
function peg$parsegroupLinkRest() {
|
|
1334
|
+
let s0, s1, s2;
|
|
1335
|
+
s0 = peg$currPos;
|
|
1336
|
+
s1 = peg$parseeol();
|
|
1337
|
+
if (s1 !== peg$FAILED) {
|
|
1338
|
+
peg$savedPos = s0;
|
|
1339
|
+
s1 = peg$f13();
|
|
1340
|
+
}
|
|
1341
|
+
s0 = s1;
|
|
1342
|
+
if (s0 === peg$FAILED) {
|
|
1343
|
+
s0 = peg$currPos;
|
|
1344
|
+
s1 = [];
|
|
1345
|
+
s2 = peg$parsesingleLineValueAndWhitespace();
|
|
1346
|
+
while (s2 !== peg$FAILED) {
|
|
1347
|
+
s1.push(s2);
|
|
1348
|
+
s2 = peg$parsesingleLineValueAndWhitespace();
|
|
1349
|
+
}
|
|
1350
|
+
s2 = peg$parseeol();
|
|
1351
|
+
if (s2 !== peg$FAILED) {
|
|
1138
1352
|
s0 = s1;
|
|
1353
|
+
} else {
|
|
1354
|
+
peg$currPos = s0;
|
|
1355
|
+
s0 = peg$FAILED;
|
|
1139
1356
|
}
|
|
1140
1357
|
}
|
|
1141
1358
|
return s0;
|
|
@@ -1185,7 +1402,7 @@ function peg$parse(input, options) {
|
|
|
1185
1402
|
} else {
|
|
1186
1403
|
s1 = peg$FAILED;
|
|
1187
1404
|
if (peg$silentFails === 0) {
|
|
1188
|
-
peg$fail(peg$
|
|
1405
|
+
peg$fail(peg$e3);
|
|
1189
1406
|
}
|
|
1190
1407
|
}
|
|
1191
1408
|
if (s1 !== peg$FAILED) {
|
|
@@ -1207,6 +1424,37 @@ function peg$parse(input, options) {
|
|
|
1207
1424
|
peg$currPos = s0;
|
|
1208
1425
|
s0 = peg$FAILED;
|
|
1209
1426
|
}
|
|
1427
|
+
if (s0 === peg$FAILED) {
|
|
1428
|
+
s0 = peg$currPos;
|
|
1429
|
+
if (input.charCodeAt(peg$currPos) === 40) {
|
|
1430
|
+
s1 = peg$c0;
|
|
1431
|
+
peg$currPos++;
|
|
1432
|
+
} else {
|
|
1433
|
+
s1 = peg$FAILED;
|
|
1434
|
+
if (peg$silentFails === 0) {
|
|
1435
|
+
peg$fail(peg$e3);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
if (s1 !== peg$FAILED) {
|
|
1439
|
+
peg$savedPos = peg$currPos;
|
|
1440
|
+
s2 = peg$f17();
|
|
1441
|
+
if (s2) {
|
|
1442
|
+
s2 = undefined;
|
|
1443
|
+
} else {
|
|
1444
|
+
s2 = peg$FAILED;
|
|
1445
|
+
}
|
|
1446
|
+
if (s2 !== peg$FAILED) {
|
|
1447
|
+
s1 = [s1, s2];
|
|
1448
|
+
s0 = s1;
|
|
1449
|
+
} else {
|
|
1450
|
+
peg$currPos = s0;
|
|
1451
|
+
s0 = peg$FAILED;
|
|
1452
|
+
}
|
|
1453
|
+
} else {
|
|
1454
|
+
peg$currPos = s0;
|
|
1455
|
+
s0 = peg$FAILED;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1210
1458
|
return s0;
|
|
1211
1459
|
}
|
|
1212
1460
|
function peg$parsenestedGroupBody() {
|
|
@@ -1222,12 +1470,12 @@ function peg$parse(input, options) {
|
|
|
1222
1470
|
} else {
|
|
1223
1471
|
s4 = peg$FAILED;
|
|
1224
1472
|
if (peg$silentFails === 0) {
|
|
1225
|
-
peg$fail(peg$
|
|
1473
|
+
peg$fail(peg$e4);
|
|
1226
1474
|
}
|
|
1227
1475
|
}
|
|
1228
1476
|
if (s4 !== peg$FAILED) {
|
|
1229
1477
|
peg$savedPos = s0;
|
|
1230
|
-
s0 = peg$
|
|
1478
|
+
s0 = peg$f18(s2);
|
|
1231
1479
|
} else {
|
|
1232
1480
|
peg$currPos = s0;
|
|
1233
1481
|
s0 = peg$FAILED;
|
|
@@ -1245,12 +1493,12 @@ function peg$parse(input, options) {
|
|
|
1245
1493
|
} else {
|
|
1246
1494
|
s2 = peg$FAILED;
|
|
1247
1495
|
if (peg$silentFails === 0) {
|
|
1248
|
-
peg$fail(peg$
|
|
1496
|
+
peg$fail(peg$e4);
|
|
1249
1497
|
}
|
|
1250
1498
|
}
|
|
1251
1499
|
if (s2 !== peg$FAILED) {
|
|
1252
1500
|
peg$savedPos = s0;
|
|
1253
|
-
s0 = peg$
|
|
1501
|
+
s0 = peg$f19();
|
|
1254
1502
|
} else {
|
|
1255
1503
|
peg$currPos = s0;
|
|
1256
1504
|
s0 = peg$FAILED;
|
|
@@ -1261,7 +1509,7 @@ function peg$parse(input, options) {
|
|
|
1261
1509
|
function peg$parseENTER_NESTED_CONTEXT() {
|
|
1262
1510
|
let s0;
|
|
1263
1511
|
peg$savedPos = peg$currPos;
|
|
1264
|
-
s0 = peg$
|
|
1512
|
+
s0 = peg$f20();
|
|
1265
1513
|
if (s0) {
|
|
1266
1514
|
s0 = undefined;
|
|
1267
1515
|
} else {
|
|
@@ -1276,7 +1524,7 @@ function peg$parse(input, options) {
|
|
|
1276
1524
|
s2 = peg$parsereferenceOrLink();
|
|
1277
1525
|
if (s2 !== peg$FAILED) {
|
|
1278
1526
|
peg$savedPos = s0;
|
|
1279
|
-
s0 = peg$
|
|
1527
|
+
s0 = peg$f21(s2);
|
|
1280
1528
|
} else {
|
|
1281
1529
|
peg$currPos = s0;
|
|
1282
1530
|
s0 = peg$FAILED;
|
|
@@ -1298,7 +1546,7 @@ function peg$parse(input, options) {
|
|
|
1298
1546
|
}
|
|
1299
1547
|
if (s1 !== peg$FAILED) {
|
|
1300
1548
|
peg$savedPos = s0;
|
|
1301
|
-
s1 = peg$
|
|
1549
|
+
s1 = peg$f22(s1);
|
|
1302
1550
|
}
|
|
1303
1551
|
s0 = s1;
|
|
1304
1552
|
return s0;
|
|
@@ -1316,14 +1564,14 @@ function peg$parse(input, options) {
|
|
|
1316
1564
|
} else {
|
|
1317
1565
|
s4 = peg$FAILED;
|
|
1318
1566
|
if (peg$silentFails === 0) {
|
|
1319
|
-
peg$fail(peg$
|
|
1567
|
+
peg$fail(peg$e5);
|
|
1320
1568
|
}
|
|
1321
1569
|
}
|
|
1322
1570
|
if (s4 !== peg$FAILED) {
|
|
1323
1571
|
s5 = peg$parsesingleLineValues();
|
|
1324
1572
|
if (s5 !== peg$FAILED) {
|
|
1325
1573
|
peg$savedPos = s0;
|
|
1326
|
-
s0 = peg$
|
|
1574
|
+
s0 = peg$f23(s2, s5);
|
|
1327
1575
|
} else {
|
|
1328
1576
|
peg$currPos = s0;
|
|
1329
1577
|
s0 = peg$FAILED;
|
|
@@ -1344,7 +1592,7 @@ function peg$parse(input, options) {
|
|
|
1344
1592
|
s1 = peg$parsesingleLineValues();
|
|
1345
1593
|
if (s1 !== peg$FAILED) {
|
|
1346
1594
|
peg$savedPos = s0;
|
|
1347
|
-
s1 = peg$
|
|
1595
|
+
s1 = peg$f24(s1);
|
|
1348
1596
|
}
|
|
1349
1597
|
s0 = s1;
|
|
1350
1598
|
return s0;
|
|
@@ -1361,14 +1609,14 @@ function peg$parse(input, options) {
|
|
|
1361
1609
|
} else {
|
|
1362
1610
|
s3 = peg$FAILED;
|
|
1363
1611
|
if (peg$silentFails === 0) {
|
|
1364
|
-
peg$fail(peg$
|
|
1612
|
+
peg$fail(peg$e5);
|
|
1365
1613
|
}
|
|
1366
1614
|
}
|
|
1367
1615
|
if (s3 !== peg$FAILED) {
|
|
1368
1616
|
s4 = peg$parseeol();
|
|
1369
1617
|
if (s4 !== peg$FAILED) {
|
|
1370
1618
|
peg$savedPos = s0;
|
|
1371
|
-
s0 = peg$
|
|
1619
|
+
s0 = peg$f25(s1);
|
|
1372
1620
|
} else {
|
|
1373
1621
|
peg$currPos = s0;
|
|
1374
1622
|
s0 = peg$FAILED;
|
|
@@ -1406,7 +1654,7 @@ function peg$parse(input, options) {
|
|
|
1406
1654
|
}
|
|
1407
1655
|
if (s1 !== peg$FAILED) {
|
|
1408
1656
|
peg$savedPos = s0;
|
|
1409
|
-
s1 = peg$
|
|
1657
|
+
s1 = peg$f26(s1);
|
|
1410
1658
|
}
|
|
1411
1659
|
s0 = s1;
|
|
1412
1660
|
return s0;
|
|
@@ -1433,7 +1681,7 @@ function peg$parse(input, options) {
|
|
|
1433
1681
|
} else {
|
|
1434
1682
|
s2 = peg$FAILED;
|
|
1435
1683
|
if (peg$silentFails === 0) {
|
|
1436
|
-
peg$fail(peg$
|
|
1684
|
+
peg$fail(peg$e6);
|
|
1437
1685
|
}
|
|
1438
1686
|
}
|
|
1439
1687
|
peg$silentFails--;
|
|
@@ -1445,7 +1693,7 @@ function peg$parse(input, options) {
|
|
|
1445
1693
|
}
|
|
1446
1694
|
if (s1 !== peg$FAILED) {
|
|
1447
1695
|
peg$savedPos = peg$currPos;
|
|
1448
|
-
s2 = peg$
|
|
1696
|
+
s2 = peg$f27();
|
|
1449
1697
|
if (s2) {
|
|
1450
1698
|
s2 = undefined;
|
|
1451
1699
|
} else {
|
|
@@ -1455,7 +1703,7 @@ function peg$parse(input, options) {
|
|
|
1455
1703
|
s3 = peg$parseconsumeDouble();
|
|
1456
1704
|
if (s3 !== peg$FAILED) {
|
|
1457
1705
|
peg$savedPos = s0;
|
|
1458
|
-
s0 = peg$
|
|
1706
|
+
s0 = peg$f28(s3);
|
|
1459
1707
|
} else {
|
|
1460
1708
|
peg$currPos = s0;
|
|
1461
1709
|
s0 = peg$FAILED;
|
|
@@ -1479,7 +1727,7 @@ function peg$parse(input, options) {
|
|
|
1479
1727
|
} else {
|
|
1480
1728
|
s1 = peg$FAILED;
|
|
1481
1729
|
if (peg$silentFails === 0) {
|
|
1482
|
-
peg$fail(peg$
|
|
1730
|
+
peg$fail(peg$e2);
|
|
1483
1731
|
}
|
|
1484
1732
|
}
|
|
1485
1733
|
if (s1 !== peg$FAILED) {
|
|
@@ -1490,7 +1738,7 @@ function peg$parse(input, options) {
|
|
|
1490
1738
|
s3 = peg$parseconsumeDoubleMore();
|
|
1491
1739
|
}
|
|
1492
1740
|
peg$savedPos = s0;
|
|
1493
|
-
s0 = peg$
|
|
1741
|
+
s0 = peg$f29(s1, s2);
|
|
1494
1742
|
} else {
|
|
1495
1743
|
peg$currPos = s0;
|
|
1496
1744
|
s0 = peg$FAILED;
|
|
@@ -1501,7 +1749,7 @@ function peg$parse(input, options) {
|
|
|
1501
1749
|
let s0, s1, s2;
|
|
1502
1750
|
s0 = peg$currPos;
|
|
1503
1751
|
peg$savedPos = peg$currPos;
|
|
1504
|
-
s1 = peg$
|
|
1752
|
+
s1 = peg$f30();
|
|
1505
1753
|
if (s1) {
|
|
1506
1754
|
s1 = undefined;
|
|
1507
1755
|
} else {
|
|
@@ -1514,12 +1762,12 @@ function peg$parse(input, options) {
|
|
|
1514
1762
|
} else {
|
|
1515
1763
|
s2 = peg$FAILED;
|
|
1516
1764
|
if (peg$silentFails === 0) {
|
|
1517
|
-
peg$fail(peg$
|
|
1765
|
+
peg$fail(peg$e2);
|
|
1518
1766
|
}
|
|
1519
1767
|
}
|
|
1520
1768
|
if (s2 !== peg$FAILED) {
|
|
1521
1769
|
peg$savedPos = s0;
|
|
1522
|
-
s0 = peg$
|
|
1770
|
+
s0 = peg$f31(s2);
|
|
1523
1771
|
} else {
|
|
1524
1772
|
peg$currPos = s0;
|
|
1525
1773
|
s0 = peg$FAILED;
|
|
@@ -1553,7 +1801,7 @@ function peg$parse(input, options) {
|
|
|
1553
1801
|
}
|
|
1554
1802
|
if (s1 !== peg$FAILED) {
|
|
1555
1803
|
peg$savedPos = peg$currPos;
|
|
1556
|
-
s2 = peg$
|
|
1804
|
+
s2 = peg$f32();
|
|
1557
1805
|
if (s2) {
|
|
1558
1806
|
s2 = undefined;
|
|
1559
1807
|
} else {
|
|
@@ -1563,7 +1811,7 @@ function peg$parse(input, options) {
|
|
|
1563
1811
|
s3 = peg$parseconsumeSingle();
|
|
1564
1812
|
if (s3 !== peg$FAILED) {
|
|
1565
1813
|
peg$savedPos = s0;
|
|
1566
|
-
s0 = peg$
|
|
1814
|
+
s0 = peg$f33(s3);
|
|
1567
1815
|
} else {
|
|
1568
1816
|
peg$currPos = s0;
|
|
1569
1817
|
s0 = peg$FAILED;
|
|
@@ -1587,7 +1835,7 @@ function peg$parse(input, options) {
|
|
|
1587
1835
|
} else {
|
|
1588
1836
|
s1 = peg$FAILED;
|
|
1589
1837
|
if (peg$silentFails === 0) {
|
|
1590
|
-
peg$fail(peg$
|
|
1838
|
+
peg$fail(peg$e2);
|
|
1591
1839
|
}
|
|
1592
1840
|
}
|
|
1593
1841
|
if (s1 !== peg$FAILED) {
|
|
@@ -1598,7 +1846,7 @@ function peg$parse(input, options) {
|
|
|
1598
1846
|
s3 = peg$parseconsumeSingleMore();
|
|
1599
1847
|
}
|
|
1600
1848
|
peg$savedPos = s0;
|
|
1601
|
-
s0 = peg$
|
|
1849
|
+
s0 = peg$f34(s1, s2);
|
|
1602
1850
|
} else {
|
|
1603
1851
|
peg$currPos = s0;
|
|
1604
1852
|
s0 = peg$FAILED;
|
|
@@ -1609,7 +1857,7 @@ function peg$parse(input, options) {
|
|
|
1609
1857
|
let s0, s1, s2;
|
|
1610
1858
|
s0 = peg$currPos;
|
|
1611
1859
|
peg$savedPos = peg$currPos;
|
|
1612
|
-
s1 = peg$
|
|
1860
|
+
s1 = peg$f35();
|
|
1613
1861
|
if (s1) {
|
|
1614
1862
|
s1 = undefined;
|
|
1615
1863
|
} else {
|
|
@@ -1622,12 +1870,12 @@ function peg$parse(input, options) {
|
|
|
1622
1870
|
} else {
|
|
1623
1871
|
s2 = peg$FAILED;
|
|
1624
1872
|
if (peg$silentFails === 0) {
|
|
1625
|
-
peg$fail(peg$
|
|
1873
|
+
peg$fail(peg$e2);
|
|
1626
1874
|
}
|
|
1627
1875
|
}
|
|
1628
1876
|
if (s2 !== peg$FAILED) {
|
|
1629
1877
|
peg$savedPos = s0;
|
|
1630
|
-
s0 = peg$
|
|
1878
|
+
s0 = peg$f36(s2);
|
|
1631
1879
|
} else {
|
|
1632
1880
|
peg$currPos = s0;
|
|
1633
1881
|
s0 = peg$FAILED;
|
|
@@ -1661,7 +1909,7 @@ function peg$parse(input, options) {
|
|
|
1661
1909
|
}
|
|
1662
1910
|
if (s1 !== peg$FAILED) {
|
|
1663
1911
|
peg$savedPos = peg$currPos;
|
|
1664
|
-
s2 = peg$
|
|
1912
|
+
s2 = peg$f37();
|
|
1665
1913
|
if (s2) {
|
|
1666
1914
|
s2 = undefined;
|
|
1667
1915
|
} else {
|
|
@@ -1671,7 +1919,7 @@ function peg$parse(input, options) {
|
|
|
1671
1919
|
s3 = peg$parseconsumeBacktick();
|
|
1672
1920
|
if (s3 !== peg$FAILED) {
|
|
1673
1921
|
peg$savedPos = s0;
|
|
1674
|
-
s0 = peg$
|
|
1922
|
+
s0 = peg$f38(s3);
|
|
1675
1923
|
} else {
|
|
1676
1924
|
peg$currPos = s0;
|
|
1677
1925
|
s0 = peg$FAILED;
|
|
@@ -1695,7 +1943,7 @@ function peg$parse(input, options) {
|
|
|
1695
1943
|
} else {
|
|
1696
1944
|
s1 = peg$FAILED;
|
|
1697
1945
|
if (peg$silentFails === 0) {
|
|
1698
|
-
peg$fail(peg$
|
|
1946
|
+
peg$fail(peg$e2);
|
|
1699
1947
|
}
|
|
1700
1948
|
}
|
|
1701
1949
|
if (s1 !== peg$FAILED) {
|
|
@@ -1706,7 +1954,7 @@ function peg$parse(input, options) {
|
|
|
1706
1954
|
s3 = peg$parseconsumeBacktickMore();
|
|
1707
1955
|
}
|
|
1708
1956
|
peg$savedPos = s0;
|
|
1709
|
-
s0 = peg$
|
|
1957
|
+
s0 = peg$f39(s1, s2);
|
|
1710
1958
|
} else {
|
|
1711
1959
|
peg$currPos = s0;
|
|
1712
1960
|
s0 = peg$FAILED;
|
|
@@ -1717,7 +1965,7 @@ function peg$parse(input, options) {
|
|
|
1717
1965
|
let s0, s1, s2;
|
|
1718
1966
|
s0 = peg$currPos;
|
|
1719
1967
|
peg$savedPos = peg$currPos;
|
|
1720
|
-
s1 = peg$
|
|
1968
|
+
s1 = peg$f40();
|
|
1721
1969
|
if (s1) {
|
|
1722
1970
|
s1 = undefined;
|
|
1723
1971
|
} else {
|
|
@@ -1730,12 +1978,12 @@ function peg$parse(input, options) {
|
|
|
1730
1978
|
} else {
|
|
1731
1979
|
s2 = peg$FAILED;
|
|
1732
1980
|
if (peg$silentFails === 0) {
|
|
1733
|
-
peg$fail(peg$
|
|
1981
|
+
peg$fail(peg$e2);
|
|
1734
1982
|
}
|
|
1735
1983
|
}
|
|
1736
1984
|
if (s2 !== peg$FAILED) {
|
|
1737
1985
|
peg$savedPos = s0;
|
|
1738
|
-
s0 = peg$
|
|
1986
|
+
s0 = peg$f41(s2);
|
|
1739
1987
|
} else {
|
|
1740
1988
|
peg$currPos = s0;
|
|
1741
1989
|
s0 = peg$FAILED;
|
|
@@ -1746,6 +1994,15 @@ function peg$parse(input, options) {
|
|
|
1746
1994
|
}
|
|
1747
1995
|
return s0;
|
|
1748
1996
|
}
|
|
1997
|
+
function peg$parseSAVE_INDENTATION() {
|
|
1998
|
+
let s0, s1;
|
|
1999
|
+
s0 = peg$currPos;
|
|
2000
|
+
s1 = "";
|
|
2001
|
+
peg$savedPos = s0;
|
|
2002
|
+
s1 = peg$f42();
|
|
2003
|
+
s0 = s1;
|
|
2004
|
+
return s0;
|
|
2005
|
+
}
|
|
1749
2006
|
function peg$parseSET_BASE_INDENTATION() {
|
|
1750
2007
|
let s0, s1, s2;
|
|
1751
2008
|
s0 = peg$currPos;
|
|
@@ -1772,7 +2029,7 @@ function peg$parse(input, options) {
|
|
|
1772
2029
|
}
|
|
1773
2030
|
}
|
|
1774
2031
|
peg$savedPos = s0;
|
|
1775
|
-
s1 = peg$
|
|
2032
|
+
s1 = peg$f43(s1);
|
|
1776
2033
|
s0 = s1;
|
|
1777
2034
|
return s0;
|
|
1778
2035
|
}
|
|
@@ -1802,7 +2059,7 @@ function peg$parse(input, options) {
|
|
|
1802
2059
|
}
|
|
1803
2060
|
}
|
|
1804
2061
|
peg$savedPos = peg$currPos;
|
|
1805
|
-
s2 = peg$
|
|
2062
|
+
s2 = peg$f44(s1);
|
|
1806
2063
|
if (s2) {
|
|
1807
2064
|
s2 = undefined;
|
|
1808
2065
|
} else {
|
|
@@ -1810,7 +2067,7 @@ function peg$parse(input, options) {
|
|
|
1810
2067
|
}
|
|
1811
2068
|
if (s2 !== peg$FAILED) {
|
|
1812
2069
|
peg$savedPos = s0;
|
|
1813
|
-
s0 = peg$
|
|
2070
|
+
s0 = peg$f45(s1);
|
|
1814
2071
|
} else {
|
|
1815
2072
|
peg$currPos = s0;
|
|
1816
2073
|
s0 = peg$FAILED;
|
|
@@ -1843,7 +2100,7 @@ function peg$parse(input, options) {
|
|
|
1843
2100
|
}
|
|
1844
2101
|
}
|
|
1845
2102
|
peg$savedPos = peg$currPos;
|
|
1846
|
-
s2 = peg$
|
|
2103
|
+
s2 = peg$f46(s1);
|
|
1847
2104
|
if (s2) {
|
|
1848
2105
|
s2 = undefined;
|
|
1849
2106
|
} else {
|
|
@@ -2054,7 +2311,7 @@ function peg$parse(input, options) {
|
|
|
2054
2311
|
let s0, s1, s2, s3;
|
|
2055
2312
|
s0 = peg$currPos;
|
|
2056
2313
|
peg$savedPos = peg$currPos;
|
|
2057
|
-
s1 = peg$
|
|
2314
|
+
s1 = peg$f47();
|
|
2058
2315
|
if (s1) {
|
|
2059
2316
|
s1 = undefined;
|
|
2060
2317
|
} else {
|
|
@@ -2069,7 +2326,7 @@ function peg$parse(input, options) {
|
|
|
2069
2326
|
} else {
|
|
2070
2327
|
s3 = peg$FAILED;
|
|
2071
2328
|
if (peg$silentFails === 0) {
|
|
2072
|
-
peg$fail(peg$
|
|
2329
|
+
peg$fail(peg$e4);
|
|
2073
2330
|
}
|
|
2074
2331
|
}
|
|
2075
2332
|
peg$silentFails--;
|
|
@@ -2102,7 +2359,7 @@ function peg$parse(input, options) {
|
|
|
2102
2359
|
} else {
|
|
2103
2360
|
s1 = peg$FAILED;
|
|
2104
2361
|
if (peg$silentFails === 0) {
|
|
2105
|
-
peg$fail(peg$
|
|
2362
|
+
peg$fail(peg$e2);
|
|
2106
2363
|
}
|
|
2107
2364
|
}
|
|
2108
2365
|
peg$silentFails--;
|
|
@@ -2179,12 +2436,17 @@ function peg$parse(input, options) {
|
|
|
2179
2436
|
let indentationStack = [0];
|
|
2180
2437
|
let baseIndentation = null;
|
|
2181
2438
|
let contextStack = [];
|
|
2439
|
+
let unreadableLines = new Set;
|
|
2182
2440
|
function resetState() {
|
|
2183
2441
|
indentationStack = [0];
|
|
2184
2442
|
baseIndentation = null;
|
|
2185
2443
|
contextStack = [];
|
|
2444
|
+
unreadableLines = new Set;
|
|
2186
2445
|
return true;
|
|
2187
2446
|
}
|
|
2447
|
+
function lineKey(position) {
|
|
2448
|
+
return contextStack.length > 0 ? -1 - position : position;
|
|
2449
|
+
}
|
|
2188
2450
|
function enterNestedContext() {
|
|
2189
2451
|
contextStack.push({ indentationStack, baseIndentation });
|
|
2190
2452
|
indentationStack = [0];
|
|
@@ -2229,61 +2491,12 @@ function peg$parse(input, options) {
|
|
|
2229
2491
|
function getCurrentIndentation() {
|
|
2230
2492
|
return indentationStack[indentationStack.length - 1];
|
|
2231
2493
|
}
|
|
2232
|
-
|
|
2233
|
-
let depth = 0;
|
|
2234
|
-
let hasVisible = false;
|
|
2235
|
-
for (const c of content) {
|
|
2236
|
-
if (c === "(") {
|
|
2237
|
-
depth++;
|
|
2238
|
-
} else if (c === ")") {
|
|
2239
|
-
depth--;
|
|
2240
|
-
if (depth < 0) {
|
|
2241
|
-
return false;
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
if (!/[ \t\n\r]/.test(c)) {
|
|
2245
|
-
hasVisible = true;
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
return hasVisible && depth === 0;
|
|
2249
|
-
}
|
|
2494
|
+
const delimitedReferences = new DelimitedReferences(input);
|
|
2250
2495
|
function parseQuotedStringAt(inputStr, startPos, quoteChar) {
|
|
2251
2496
|
if (startPos >= inputStr.length || inputStr[startPos] !== quoteChar) {
|
|
2252
2497
|
return null;
|
|
2253
2498
|
}
|
|
2254
|
-
|
|
2255
|
-
let pos = startPos;
|
|
2256
|
-
while (pos < inputStr.length && inputStr[pos] === quoteChar) {
|
|
2257
|
-
quoteCount++;
|
|
2258
|
-
pos++;
|
|
2259
|
-
}
|
|
2260
|
-
const isEvenRun = quoteCount % 2 === 0;
|
|
2261
|
-
const emptyReference = isEvenRun ? { value: "", length: quoteCount } : null;
|
|
2262
|
-
const closeSeq = quoteChar.repeat(quoteCount);
|
|
2263
|
-
const escapeSeq = quoteChar.repeat(quoteCount * 2);
|
|
2264
|
-
let content = "";
|
|
2265
|
-
while (pos < inputStr.length) {
|
|
2266
|
-
if (inputStr.substr(pos, escapeSeq.length) === escapeSeq) {
|
|
2267
|
-
content += closeSeq;
|
|
2268
|
-
pos += escapeSeq.length;
|
|
2269
|
-
continue;
|
|
2270
|
-
}
|
|
2271
|
-
if (inputStr.substr(pos, quoteCount) === closeSeq) {
|
|
2272
|
-
const afterClose = pos + quoteCount;
|
|
2273
|
-
if (afterClose >= inputStr.length || inputStr[afterClose] !== quoteChar) {
|
|
2274
|
-
if (isEvenRun && !isSubstantiveBody(content)) {
|
|
2275
|
-
return emptyReference;
|
|
2276
|
-
}
|
|
2277
|
-
return {
|
|
2278
|
-
value: content,
|
|
2279
|
-
length: afterClose - startPos
|
|
2280
|
-
};
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
content += inputStr[pos];
|
|
2284
|
-
pos++;
|
|
2285
|
-
}
|
|
2286
|
-
return emptyReference;
|
|
2499
|
+
return delimitedReferences.readAt(startPos);
|
|
2287
2500
|
}
|
|
2288
2501
|
let parsedValue = null;
|
|
2289
2502
|
let parsedLength = 0;
|
|
@@ -2642,12 +2855,13 @@ function structurallyComplete(document, comments) {
|
|
|
2642
2855
|
`, "\r", "(", ":"];
|
|
2643
2856
|
const beforeComment = [" ", "\t", `
|
|
2644
2857
|
`, "\r"];
|
|
2858
|
+
const references = new DelimitedReferences(document);
|
|
2645
2859
|
let depth = 0;
|
|
2646
2860
|
for (let position = 0;position < document.length; position++) {
|
|
2647
2861
|
const character = document[position];
|
|
2648
2862
|
const previous = position === 0 ? null : document[position - 1];
|
|
2649
2863
|
if (quotes.includes(character) && (previous === null || beforeReference.includes(previous))) {
|
|
2650
|
-
const end =
|
|
2864
|
+
const end = references.endAt(position);
|
|
2651
2865
|
if (end === null)
|
|
2652
2866
|
return false;
|
|
2653
2867
|
position = end - 1;
|