links-notation 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +216 -336
- package/package.json +7 -4
- package/src/Cst.js +9 -26
- package/src/ReferenceLiteral.js +22 -0
- package/src/StreamParser.js +33 -13
- package/src/comments.js +50 -11
- package/src/grammar.pegjs +4 -2
- package/src/parser-generated.js +110 -274
- package/src/quotes.js +13 -7
- package/tests/Comments.test.js +31 -0
- package/tests/StreamParser.test.js +13 -0
package/src/parser-generated.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by Peggy 5.1.
|
|
1
|
+
// @generated by Peggy 5.1.1.
|
|
2
2
|
//
|
|
3
3
|
// https://peggyjs.org/
|
|
4
4
|
|
|
@@ -62,10 +62,9 @@ class peg$SyntaxError extends SyntaxError {
|
|
|
62
62
|
return s;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
function
|
|
65
|
+
function escape(s, special) {
|
|
66
66
|
return unicodeEscape(s
|
|
67
|
-
.replace(
|
|
68
|
-
.replace(/"/g, "\\\"")
|
|
67
|
+
.replace(special, "\\$&")
|
|
69
68
|
.replace(/\0/g, "\\0")
|
|
70
69
|
.replace(/\t/g, "\\t")
|
|
71
70
|
.replace(/\n/g, "\\n")
|
|
@@ -74,18 +73,12 @@ class peg$SyntaxError extends SyntaxError {
|
|
|
74
73
|
.replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
function literalEscape(s) {
|
|
77
|
+
return escape(s, /[\\"]/g);
|
|
78
|
+
}
|
|
79
|
+
|
|
77
80
|
function classEscape(s) {
|
|
78
|
-
return
|
|
79
|
-
.replace(/\\/g, "\\\\")
|
|
80
|
-
.replace(/\]/g, "\\]")
|
|
81
|
-
.replace(/\^/g, "\\^")
|
|
82
|
-
.replace(/-/g, "\\-")
|
|
83
|
-
.replace(/\0/g, "\\0")
|
|
84
|
-
.replace(/\t/g, "\\t")
|
|
85
|
-
.replace(/\n/g, "\\n")
|
|
86
|
-
.replace(/\r/g, "\\r")
|
|
87
|
-
.replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
|
|
88
|
-
.replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
|
|
81
|
+
return escape(s, /[\\\]^-]/g);
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
const DESCRIBE_EXPECTATION_FNS = {
|
|
@@ -179,12 +172,6 @@ function peg$parse(input, options) {
|
|
|
179
172
|
const peg$c8 = "`";
|
|
180
173
|
const peg$c9 = " ";
|
|
181
174
|
|
|
182
|
-
const peg$r0 = /^[ \t]/;
|
|
183
|
-
const peg$r1 = /^[\r\n]/;
|
|
184
|
-
const peg$r2 = /^[0-9]/;
|
|
185
|
-
const peg$r3 = /^[^} \t\r\n()]/;
|
|
186
|
-
const peg$r4 = /^[ \t\n\r]/;
|
|
187
|
-
const peg$r5 = /^[^ \t\n\r(:)]/;
|
|
188
175
|
|
|
189
176
|
const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
|
|
190
177
|
const peg$e1 = peg$classExpectation(["\r", "\n"], false, false, false);
|
|
@@ -314,6 +301,7 @@ function peg$parse(input, options) {
|
|
|
314
301
|
let peg$silentFails = options.peg$silentFails | 0;
|
|
315
302
|
|
|
316
303
|
let peg$result;
|
|
304
|
+
let peg$charCode;
|
|
317
305
|
|
|
318
306
|
if (options.startRule) {
|
|
319
307
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
@@ -540,62 +528,22 @@ function peg$parse(input, options) {
|
|
|
540
528
|
let s0, s1, s2, s3;
|
|
541
529
|
|
|
542
530
|
s0 = [];
|
|
543
|
-
|
|
544
|
-
s2 = [];
|
|
545
|
-
s3 = input.charAt(peg$currPos);
|
|
546
|
-
if (peg$r0.test(s3)) {
|
|
547
|
-
peg$currPos++;
|
|
548
|
-
} else {
|
|
549
|
-
s3 = peg$FAILED;
|
|
550
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
551
|
-
}
|
|
552
|
-
while (s3 !== peg$FAILED) {
|
|
553
|
-
s2.push(s3);
|
|
554
|
-
s3 = input.charAt(peg$currPos);
|
|
555
|
-
if (peg$r0.test(s3)) {
|
|
556
|
-
peg$currPos++;
|
|
557
|
-
} else {
|
|
558
|
-
s3 = peg$FAILED;
|
|
559
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
s3 = input.charAt(peg$currPos);
|
|
563
|
-
if (peg$r1.test(s3)) {
|
|
564
|
-
peg$currPos++;
|
|
565
|
-
} else {
|
|
566
|
-
s3 = peg$FAILED;
|
|
567
|
-
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
568
|
-
}
|
|
569
|
-
if (s3 !== peg$FAILED) {
|
|
570
|
-
s2 = [s2, s3];
|
|
571
|
-
s1 = s2;
|
|
572
|
-
} else {
|
|
573
|
-
peg$currPos = s1;
|
|
574
|
-
s1 = peg$FAILED;
|
|
575
|
-
}
|
|
576
|
-
while (s1 !== peg$FAILED) {
|
|
577
|
-
s0.push(s1);
|
|
531
|
+
for (;;) {
|
|
578
532
|
s1 = peg$currPos;
|
|
579
533
|
s2 = [];
|
|
580
|
-
|
|
581
|
-
if (peg$r0.test(s3)) {
|
|
582
|
-
peg$currPos++;
|
|
583
|
-
} else {
|
|
584
|
-
s3 = peg$FAILED;
|
|
585
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
586
|
-
}
|
|
587
|
-
while (s3 !== peg$FAILED) {
|
|
588
|
-
s2.push(s3);
|
|
534
|
+
for (;;) {
|
|
589
535
|
s3 = input.charAt(peg$currPos);
|
|
590
|
-
if (peg$
|
|
536
|
+
if ((peg$charCode = s3.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
|
|
591
537
|
peg$currPos++;
|
|
592
538
|
} else {
|
|
593
539
|
s3 = peg$FAILED;
|
|
594
540
|
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
595
541
|
}
|
|
542
|
+
if (s3 === peg$FAILED) { break; }
|
|
543
|
+
s2.push(s3);
|
|
596
544
|
}
|
|
597
545
|
s3 = input.charAt(peg$currPos);
|
|
598
|
-
if (peg$
|
|
546
|
+
if ((peg$charCode = s3.charCodeAt(0), peg$charCode === 13 || peg$charCode === 10)) {
|
|
599
547
|
peg$currPos++;
|
|
600
548
|
} else {
|
|
601
549
|
s3 = peg$FAILED;
|
|
@@ -608,6 +556,8 @@ function peg$parse(input, options) {
|
|
|
608
556
|
peg$currPos = s1;
|
|
609
557
|
s1 = peg$FAILED;
|
|
610
558
|
}
|
|
559
|
+
if (s1 === peg$FAILED) { break; }
|
|
560
|
+
s0.push(s1);
|
|
611
561
|
}
|
|
612
562
|
|
|
613
563
|
return s0;
|
|
@@ -620,10 +570,10 @@ function peg$parse(input, options) {
|
|
|
620
570
|
s1 = peg$parsefirstLine();
|
|
621
571
|
if (s1 !== peg$FAILED) {
|
|
622
572
|
s2 = [];
|
|
623
|
-
|
|
624
|
-
while (s3 !== peg$FAILED) {
|
|
625
|
-
s2.push(s3);
|
|
573
|
+
for (;;) {
|
|
626
574
|
s3 = peg$parseline();
|
|
575
|
+
if (s3 === peg$FAILED) { break; }
|
|
576
|
+
s2.push(s3);
|
|
627
577
|
}
|
|
628
578
|
peg$savedPos = s0;
|
|
629
579
|
s0 = peg$f4(s1, s2);
|
|
@@ -890,10 +840,10 @@ function peg$parse(input, options) {
|
|
|
890
840
|
if (s0 === peg$FAILED) {
|
|
891
841
|
s0 = peg$currPos;
|
|
892
842
|
s1 = [];
|
|
893
|
-
|
|
894
|
-
while (s2 !== peg$FAILED) {
|
|
895
|
-
s1.push(s2);
|
|
843
|
+
for (;;) {
|
|
896
844
|
s2 = peg$parsesingleLineValueAndWhitespace();
|
|
845
|
+
if (s2 === peg$FAILED) { break; }
|
|
846
|
+
s1.push(s2);
|
|
897
847
|
}
|
|
898
848
|
s2 = peg$parseeol();
|
|
899
849
|
if (s2 !== peg$FAILED) {
|
|
@@ -1118,13 +1068,12 @@ function peg$parse(input, options) {
|
|
|
1118
1068
|
|
|
1119
1069
|
s0 = peg$currPos;
|
|
1120
1070
|
s1 = [];
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
} else {
|
|
1071
|
+
for (;;) {
|
|
1072
|
+
s2 = peg$parsesingleLineValueAndWhitespace();
|
|
1073
|
+
if (s2 === peg$FAILED) { break; }
|
|
1074
|
+
s1.push(s2);
|
|
1075
|
+
}
|
|
1076
|
+
if (s1.length < 1) {
|
|
1128
1077
|
s1 = peg$FAILED;
|
|
1129
1078
|
}
|
|
1130
1079
|
if (s1 !== peg$FAILED) {
|
|
@@ -1289,25 +1238,18 @@ function peg$parse(input, options) {
|
|
|
1289
1238
|
}
|
|
1290
1239
|
if (s5 !== peg$FAILED) {
|
|
1291
1240
|
s6 = [];
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
peg$
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
if (s7 !== peg$FAILED) {
|
|
1300
|
-
while (s7 !== peg$FAILED) {
|
|
1301
|
-
s6.push(s7);
|
|
1302
|
-
s7 = input.charAt(peg$currPos);
|
|
1303
|
-
if (peg$r2.test(s7)) {
|
|
1304
|
-
peg$currPos++;
|
|
1305
|
-
} else {
|
|
1306
|
-
s7 = peg$FAILED;
|
|
1307
|
-
if (peg$silentFails === 0) { peg$fail(peg$e7); }
|
|
1308
|
-
}
|
|
1241
|
+
for (;;) {
|
|
1242
|
+
s7 = input.charAt(peg$currPos);
|
|
1243
|
+
if ((peg$charCode = s7.charCodeAt(0), (peg$charCode >= 48 && peg$charCode <= 57))) {
|
|
1244
|
+
peg$currPos++;
|
|
1245
|
+
} else {
|
|
1246
|
+
s7 = peg$FAILED;
|
|
1247
|
+
if (peg$silentFails === 0) { peg$fail(peg$e7); }
|
|
1309
1248
|
}
|
|
1310
|
-
|
|
1249
|
+
if (s7 === peg$FAILED) { break; }
|
|
1250
|
+
s6.push(s7);
|
|
1251
|
+
}
|
|
1252
|
+
if (s6.length < 1) {
|
|
1311
1253
|
s6 = peg$FAILED;
|
|
1312
1254
|
}
|
|
1313
1255
|
if (s6 !== peg$FAILED) {
|
|
@@ -1320,22 +1262,16 @@ function peg$parse(input, options) {
|
|
|
1320
1262
|
}
|
|
1321
1263
|
if (s7 !== peg$FAILED) {
|
|
1322
1264
|
s8 = [];
|
|
1323
|
-
|
|
1324
|
-
if (peg$r3.test(s9)) {
|
|
1325
|
-
peg$currPos++;
|
|
1326
|
-
} else {
|
|
1327
|
-
s9 = peg$FAILED;
|
|
1328
|
-
if (peg$silentFails === 0) { peg$fail(peg$e9); }
|
|
1329
|
-
}
|
|
1330
|
-
while (s9 !== peg$FAILED) {
|
|
1331
|
-
s8.push(s9);
|
|
1265
|
+
for (;;) {
|
|
1332
1266
|
s9 = input.charAt(peg$currPos);
|
|
1333
|
-
if (peg$
|
|
1267
|
+
if (s9 !== "" && !(peg$charCode = s9.charCodeAt(0), peg$charCode === 125 || peg$charCode === 32 || peg$charCode === 9 || peg$charCode === 13 || peg$charCode === 10 || peg$charCode === 40 || peg$charCode === 41)) {
|
|
1334
1268
|
peg$currPos++;
|
|
1335
1269
|
} else {
|
|
1336
1270
|
s9 = peg$FAILED;
|
|
1337
1271
|
if (peg$silentFails === 0) { peg$fail(peg$e9); }
|
|
1338
1272
|
}
|
|
1273
|
+
if (s9 === peg$FAILED) { break; }
|
|
1274
|
+
s8.push(s9);
|
|
1339
1275
|
}
|
|
1340
1276
|
if (input.charCodeAt(peg$currPos) === 125) {
|
|
1341
1277
|
s9 = peg$c5;
|
|
@@ -1400,13 +1336,12 @@ function peg$parse(input, options) {
|
|
|
1400
1336
|
}
|
|
1401
1337
|
if (s1 !== peg$FAILED) {
|
|
1402
1338
|
s2 = [];
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
} else {
|
|
1339
|
+
for (;;) {
|
|
1340
|
+
s3 = peg$parsereferenceSymbol();
|
|
1341
|
+
if (s3 === peg$FAILED) { break; }
|
|
1342
|
+
s2.push(s3);
|
|
1343
|
+
}
|
|
1344
|
+
if (s2.length < 1) {
|
|
1410
1345
|
s2 = peg$FAILED;
|
|
1411
1346
|
}
|
|
1412
1347
|
if (s2 !== peg$FAILED) {
|
|
@@ -1500,10 +1435,10 @@ function peg$parse(input, options) {
|
|
|
1500
1435
|
}
|
|
1501
1436
|
if (s1 !== peg$FAILED) {
|
|
1502
1437
|
s2 = [];
|
|
1503
|
-
|
|
1504
|
-
while (s3 !== peg$FAILED) {
|
|
1505
|
-
s2.push(s3);
|
|
1438
|
+
for (;;) {
|
|
1506
1439
|
s3 = peg$parseconsumeDoubleMore();
|
|
1440
|
+
if (s3 === peg$FAILED) { break; }
|
|
1441
|
+
s2.push(s3);
|
|
1507
1442
|
}
|
|
1508
1443
|
peg$savedPos = s0;
|
|
1509
1444
|
s0 = peg$f36(s1, s2);
|
|
@@ -1611,10 +1546,10 @@ function peg$parse(input, options) {
|
|
|
1611
1546
|
}
|
|
1612
1547
|
if (s1 !== peg$FAILED) {
|
|
1613
1548
|
s2 = [];
|
|
1614
|
-
|
|
1615
|
-
while (s3 !== peg$FAILED) {
|
|
1616
|
-
s2.push(s3);
|
|
1549
|
+
for (;;) {
|
|
1617
1550
|
s3 = peg$parseconsumeSingleMore();
|
|
1551
|
+
if (s3 === peg$FAILED) { break; }
|
|
1552
|
+
s2.push(s3);
|
|
1618
1553
|
}
|
|
1619
1554
|
peg$savedPos = s0;
|
|
1620
1555
|
s0 = peg$f41(s1, s2);
|
|
@@ -1722,10 +1657,10 @@ function peg$parse(input, options) {
|
|
|
1722
1657
|
}
|
|
1723
1658
|
if (s1 !== peg$FAILED) {
|
|
1724
1659
|
s2 = [];
|
|
1725
|
-
|
|
1726
|
-
while (s3 !== peg$FAILED) {
|
|
1727
|
-
s2.push(s3);
|
|
1660
|
+
for (;;) {
|
|
1728
1661
|
s3 = peg$parseconsumeBacktickMore();
|
|
1662
|
+
if (s3 === peg$FAILED) { break; }
|
|
1663
|
+
s2.push(s3);
|
|
1729
1664
|
}
|
|
1730
1665
|
peg$savedPos = s0;
|
|
1731
1666
|
s0 = peg$f46(s1, s2);
|
|
@@ -1788,15 +1723,7 @@ function peg$parse(input, options) {
|
|
|
1788
1723
|
|
|
1789
1724
|
s0 = peg$currPos;
|
|
1790
1725
|
s1 = [];
|
|
1791
|
-
|
|
1792
|
-
s2 = peg$c9;
|
|
1793
|
-
peg$currPos++;
|
|
1794
|
-
} else {
|
|
1795
|
-
s2 = peg$FAILED;
|
|
1796
|
-
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
|
1797
|
-
}
|
|
1798
|
-
while (s2 !== peg$FAILED) {
|
|
1799
|
-
s1.push(s2);
|
|
1726
|
+
for (;;) {
|
|
1800
1727
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1801
1728
|
s2 = peg$c9;
|
|
1802
1729
|
peg$currPos++;
|
|
@@ -1804,6 +1731,8 @@ function peg$parse(input, options) {
|
|
|
1804
1731
|
s2 = peg$FAILED;
|
|
1805
1732
|
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
|
1806
1733
|
}
|
|
1734
|
+
if (s2 === peg$FAILED) { break; }
|
|
1735
|
+
s1.push(s2);
|
|
1807
1736
|
}
|
|
1808
1737
|
peg$savedPos = s0;
|
|
1809
1738
|
s1 = peg$f50(s1);
|
|
@@ -1817,15 +1746,7 @@ function peg$parse(input, options) {
|
|
|
1817
1746
|
|
|
1818
1747
|
s0 = peg$currPos;
|
|
1819
1748
|
s1 = [];
|
|
1820
|
-
|
|
1821
|
-
s2 = peg$c9;
|
|
1822
|
-
peg$currPos++;
|
|
1823
|
-
} else {
|
|
1824
|
-
s2 = peg$FAILED;
|
|
1825
|
-
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
|
1826
|
-
}
|
|
1827
|
-
while (s2 !== peg$FAILED) {
|
|
1828
|
-
s1.push(s2);
|
|
1749
|
+
for (;;) {
|
|
1829
1750
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1830
1751
|
s2 = peg$c9;
|
|
1831
1752
|
peg$currPos++;
|
|
@@ -1833,6 +1754,8 @@ function peg$parse(input, options) {
|
|
|
1833
1754
|
s2 = peg$FAILED;
|
|
1834
1755
|
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
|
1835
1756
|
}
|
|
1757
|
+
if (s2 === peg$FAILED) { break; }
|
|
1758
|
+
s1.push(s2);
|
|
1836
1759
|
}
|
|
1837
1760
|
peg$savedPos = peg$currPos;
|
|
1838
1761
|
s2 = peg$f51(s1);
|
|
@@ -1857,15 +1780,7 @@ function peg$parse(input, options) {
|
|
|
1857
1780
|
|
|
1858
1781
|
s0 = peg$currPos;
|
|
1859
1782
|
s1 = [];
|
|
1860
|
-
|
|
1861
|
-
s2 = peg$c9;
|
|
1862
|
-
peg$currPos++;
|
|
1863
|
-
} else {
|
|
1864
|
-
s2 = peg$FAILED;
|
|
1865
|
-
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
|
1866
|
-
}
|
|
1867
|
-
while (s2 !== peg$FAILED) {
|
|
1868
|
-
s1.push(s2);
|
|
1783
|
+
for (;;) {
|
|
1869
1784
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
1870
1785
|
s2 = peg$c9;
|
|
1871
1786
|
peg$currPos++;
|
|
@@ -1873,6 +1788,8 @@ function peg$parse(input, options) {
|
|
|
1873
1788
|
s2 = peg$FAILED;
|
|
1874
1789
|
if (peg$silentFails === 0) { peg$fail(peg$e14); }
|
|
1875
1790
|
}
|
|
1791
|
+
if (s2 === peg$FAILED) { break; }
|
|
1792
|
+
s1.push(s2);
|
|
1876
1793
|
}
|
|
1877
1794
|
peg$savedPos = peg$currPos;
|
|
1878
1795
|
s2 = peg$f53(s1);
|
|
@@ -1920,132 +1837,53 @@ function peg$parse(input, options) {
|
|
|
1920
1837
|
|
|
1921
1838
|
s0 = peg$currPos;
|
|
1922
1839
|
s1 = [];
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
peg$
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
if (s2 !== peg$FAILED) {
|
|
1931
|
-
while (s2 !== peg$FAILED) {
|
|
1932
|
-
s1.push(s2);
|
|
1933
|
-
s2 = input.charAt(peg$currPos);
|
|
1934
|
-
if (peg$r1.test(s2)) {
|
|
1935
|
-
peg$currPos++;
|
|
1936
|
-
} else {
|
|
1937
|
-
s2 = peg$FAILED;
|
|
1938
|
-
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
1939
|
-
}
|
|
1840
|
+
for (;;) {
|
|
1841
|
+
s2 = input.charAt(peg$currPos);
|
|
1842
|
+
if ((peg$charCode = s2.charCodeAt(0), peg$charCode === 13 || peg$charCode === 10)) {
|
|
1843
|
+
peg$currPos++;
|
|
1844
|
+
} else {
|
|
1845
|
+
s2 = peg$FAILED;
|
|
1846
|
+
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
1940
1847
|
}
|
|
1941
|
-
|
|
1848
|
+
if (s2 === peg$FAILED) { break; }
|
|
1849
|
+
s1.push(s2);
|
|
1850
|
+
}
|
|
1851
|
+
if (s1.length < 1) {
|
|
1942
1852
|
s1 = peg$FAILED;
|
|
1943
1853
|
}
|
|
1944
1854
|
if (s1 !== peg$FAILED) {
|
|
1945
1855
|
s2 = [];
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
peg$currPos++;
|
|
1951
|
-
} else {
|
|
1952
|
-
s5 = peg$FAILED;
|
|
1953
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
1954
|
-
}
|
|
1955
|
-
if (s5 !== peg$FAILED) {
|
|
1956
|
-
while (s5 !== peg$FAILED) {
|
|
1957
|
-
s4.push(s5);
|
|
1856
|
+
for (;;) {
|
|
1857
|
+
s3 = peg$currPos;
|
|
1858
|
+
s4 = [];
|
|
1859
|
+
for (;;) {
|
|
1958
1860
|
s5 = input.charAt(peg$currPos);
|
|
1959
|
-
if (peg$
|
|
1861
|
+
if ((peg$charCode = s5.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
|
|
1960
1862
|
peg$currPos++;
|
|
1961
1863
|
} else {
|
|
1962
1864
|
s5 = peg$FAILED;
|
|
1963
1865
|
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
1964
1866
|
}
|
|
1867
|
+
if (s5 === peg$FAILED) { break; }
|
|
1868
|
+
s4.push(s5);
|
|
1965
1869
|
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
}
|
|
1969
|
-
if (s4 !== peg$FAILED) {
|
|
1970
|
-
s5 = [];
|
|
1971
|
-
s6 = input.charAt(peg$currPos);
|
|
1972
|
-
if (peg$r1.test(s6)) {
|
|
1973
|
-
peg$currPos++;
|
|
1974
|
-
} else {
|
|
1975
|
-
s6 = peg$FAILED;
|
|
1976
|
-
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
1870
|
+
if (s4.length < 1) {
|
|
1871
|
+
s4 = peg$FAILED;
|
|
1977
1872
|
}
|
|
1978
|
-
if (
|
|
1979
|
-
|
|
1980
|
-
|
|
1873
|
+
if (s4 !== peg$FAILED) {
|
|
1874
|
+
s5 = [];
|
|
1875
|
+
for (;;) {
|
|
1981
1876
|
s6 = input.charAt(peg$currPos);
|
|
1982
|
-
if (peg$
|
|
1877
|
+
if ((peg$charCode = s6.charCodeAt(0), peg$charCode === 13 || peg$charCode === 10)) {
|
|
1983
1878
|
peg$currPos++;
|
|
1984
1879
|
} else {
|
|
1985
1880
|
s6 = peg$FAILED;
|
|
1986
1881
|
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
1987
1882
|
}
|
|
1883
|
+
if (s6 === peg$FAILED) { break; }
|
|
1884
|
+
s5.push(s6);
|
|
1988
1885
|
}
|
|
1989
|
-
|
|
1990
|
-
s5 = peg$FAILED;
|
|
1991
|
-
}
|
|
1992
|
-
if (s5 !== peg$FAILED) {
|
|
1993
|
-
s4 = [s4, s5];
|
|
1994
|
-
s3 = s4;
|
|
1995
|
-
} else {
|
|
1996
|
-
peg$currPos = s3;
|
|
1997
|
-
s3 = peg$FAILED;
|
|
1998
|
-
}
|
|
1999
|
-
} else {
|
|
2000
|
-
peg$currPos = s3;
|
|
2001
|
-
s3 = peg$FAILED;
|
|
2002
|
-
}
|
|
2003
|
-
while (s3 !== peg$FAILED) {
|
|
2004
|
-
s2.push(s3);
|
|
2005
|
-
s3 = peg$currPos;
|
|
2006
|
-
s4 = [];
|
|
2007
|
-
s5 = input.charAt(peg$currPos);
|
|
2008
|
-
if (peg$r0.test(s5)) {
|
|
2009
|
-
peg$currPos++;
|
|
2010
|
-
} else {
|
|
2011
|
-
s5 = peg$FAILED;
|
|
2012
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
2013
|
-
}
|
|
2014
|
-
if (s5 !== peg$FAILED) {
|
|
2015
|
-
while (s5 !== peg$FAILED) {
|
|
2016
|
-
s4.push(s5);
|
|
2017
|
-
s5 = input.charAt(peg$currPos);
|
|
2018
|
-
if (peg$r0.test(s5)) {
|
|
2019
|
-
peg$currPos++;
|
|
2020
|
-
} else {
|
|
2021
|
-
s5 = peg$FAILED;
|
|
2022
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
} else {
|
|
2026
|
-
s4 = peg$FAILED;
|
|
2027
|
-
}
|
|
2028
|
-
if (s4 !== peg$FAILED) {
|
|
2029
|
-
s5 = [];
|
|
2030
|
-
s6 = input.charAt(peg$currPos);
|
|
2031
|
-
if (peg$r1.test(s6)) {
|
|
2032
|
-
peg$currPos++;
|
|
2033
|
-
} else {
|
|
2034
|
-
s6 = peg$FAILED;
|
|
2035
|
-
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
2036
|
-
}
|
|
2037
|
-
if (s6 !== peg$FAILED) {
|
|
2038
|
-
while (s6 !== peg$FAILED) {
|
|
2039
|
-
s5.push(s6);
|
|
2040
|
-
s6 = input.charAt(peg$currPos);
|
|
2041
|
-
if (peg$r1.test(s6)) {
|
|
2042
|
-
peg$currPos++;
|
|
2043
|
-
} else {
|
|
2044
|
-
s6 = peg$FAILED;
|
|
2045
|
-
if (peg$silentFails === 0) { peg$fail(peg$e1); }
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
} else {
|
|
1886
|
+
if (s5.length < 1) {
|
|
2049
1887
|
s5 = peg$FAILED;
|
|
2050
1888
|
}
|
|
2051
1889
|
if (s5 !== peg$FAILED) {
|
|
@@ -2059,6 +1897,8 @@ function peg$parse(input, options) {
|
|
|
2059
1897
|
peg$currPos = s3;
|
|
2060
1898
|
s3 = peg$FAILED;
|
|
2061
1899
|
}
|
|
1900
|
+
if (s3 === peg$FAILED) { break; }
|
|
1901
|
+
s2.push(s3);
|
|
2062
1902
|
}
|
|
2063
1903
|
s1 = [s1, s2];
|
|
2064
1904
|
s0 = s1;
|
|
@@ -2140,22 +1980,16 @@ function peg$parse(input, options) {
|
|
|
2140
1980
|
let s0, s1;
|
|
2141
1981
|
|
|
2142
1982
|
s0 = [];
|
|
2143
|
-
|
|
2144
|
-
if (peg$r0.test(s1)) {
|
|
2145
|
-
peg$currPos++;
|
|
2146
|
-
} else {
|
|
2147
|
-
s1 = peg$FAILED;
|
|
2148
|
-
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
2149
|
-
}
|
|
2150
|
-
while (s1 !== peg$FAILED) {
|
|
2151
|
-
s0.push(s1);
|
|
1983
|
+
for (;;) {
|
|
2152
1984
|
s1 = input.charAt(peg$currPos);
|
|
2153
|
-
if (peg$
|
|
1985
|
+
if ((peg$charCode = s1.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
|
|
2154
1986
|
peg$currPos++;
|
|
2155
1987
|
} else {
|
|
2156
1988
|
s1 = peg$FAILED;
|
|
2157
1989
|
if (peg$silentFails === 0) { peg$fail(peg$e0); }
|
|
2158
1990
|
}
|
|
1991
|
+
if (s1 === peg$FAILED) { break; }
|
|
1992
|
+
s0.push(s1);
|
|
2159
1993
|
}
|
|
2160
1994
|
|
|
2161
1995
|
return s0;
|
|
@@ -2165,10 +1999,10 @@ function peg$parse(input, options) {
|
|
|
2165
1999
|
let s0, s1;
|
|
2166
2000
|
|
|
2167
2001
|
s0 = [];
|
|
2168
|
-
|
|
2169
|
-
while (s1 !== peg$FAILED) {
|
|
2170
|
-
s0.push(s1);
|
|
2002
|
+
for (;;) {
|
|
2171
2003
|
s1 = peg$parsewhiteSpaceSymbol();
|
|
2004
|
+
if (s1 === peg$FAILED) { break; }
|
|
2005
|
+
s0.push(s1);
|
|
2172
2006
|
}
|
|
2173
2007
|
|
|
2174
2008
|
return s0;
|
|
@@ -2178,7 +2012,7 @@ function peg$parse(input, options) {
|
|
|
2178
2012
|
let s0;
|
|
2179
2013
|
|
|
2180
2014
|
s0 = input.charAt(peg$currPos);
|
|
2181
|
-
if (peg$
|
|
2015
|
+
if ((peg$charCode = s0.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9 || peg$charCode === 10 || peg$charCode === 13)) {
|
|
2182
2016
|
peg$currPos++;
|
|
2183
2017
|
} else {
|
|
2184
2018
|
s0 = peg$FAILED;
|
|
@@ -2192,7 +2026,7 @@ function peg$parse(input, options) {
|
|
|
2192
2026
|
let s0;
|
|
2193
2027
|
|
|
2194
2028
|
s0 = input.charAt(peg$currPos);
|
|
2195
|
-
if (peg$
|
|
2029
|
+
if (s0 !== "" && !(peg$charCode = s0.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9 || peg$charCode === 10 || peg$charCode === 13 || peg$charCode === 40 || peg$charCode === 58 || peg$charCode === 41)) {
|
|
2196
2030
|
peg$currPos++;
|
|
2197
2031
|
} else {
|
|
2198
2032
|
s0 = peg$FAILED;
|
|
@@ -2316,8 +2150,10 @@ function peg$parse(input, options) {
|
|
|
2316
2150
|
}
|
|
2317
2151
|
|
|
2318
2152
|
// Delimited references of this document, each read once however many
|
|
2319
|
-
// alternatives ask for it (see quotes.js for how a reference is read)
|
|
2320
|
-
|
|
2153
|
+
// alternatives ask for it (see quotes.js for how a reference is read). They
|
|
2154
|
+
// are read in the document as written, as the comment reader reads them, so
|
|
2155
|
+
// blanking a comment never changes how far a reference reaches (issue #377).
|
|
2156
|
+
const delimitedReferences = new DelimitedReferences(source);
|
|
2321
2157
|
|
|
2322
2158
|
// Universal procedural parser for N-quote strings (any N >= 1)
|
|
2323
2159
|
// Parses from the given position in the input string
|
package/src/quotes.js
CHANGED
|
@@ -43,8 +43,10 @@ export class DelimitedReferences {
|
|
|
43
43
|
/**
|
|
44
44
|
* The reference opened at `start`.
|
|
45
45
|
* @param {number} start - Position of the opening delimiter
|
|
46
|
-
* @returns {{value: string, length: number}|null} What the
|
|
47
|
-
*
|
|
46
|
+
* @returns {{value: string, length: number, closed: boolean}|null} What the
|
|
47
|
+
* reference holds, how many characters it takes and whether a run closes
|
|
48
|
+
* it (an even run nothing closes is the empty reference, until a closing
|
|
49
|
+
* run is written after it), or null when nothing opens there
|
|
48
50
|
*/
|
|
49
51
|
readAt(start) {
|
|
50
52
|
if (!this.readings.has(start)) {
|
|
@@ -103,8 +105,9 @@ export class DelimitedReferences {
|
|
|
103
105
|
* reference that is as quick, since it is read once.
|
|
104
106
|
* @param {string} document - The document being read
|
|
105
107
|
* @param {number} start - Position of the opening delimiter
|
|
106
|
-
* @returns {{value: string, length: number}|null} What the
|
|
107
|
-
*
|
|
108
|
+
* @returns {{value: string, length: number, closed: boolean}|null} What the
|
|
109
|
+
* reference holds, how many characters it takes and whether a run closes it,
|
|
110
|
+
* or null when nothing opens there
|
|
108
111
|
*/
|
|
109
112
|
export function readReference(document, start) {
|
|
110
113
|
const quote = document[start];
|
|
@@ -131,10 +134,13 @@ export function readReference(document, start) {
|
|
|
131
134
|
* by the run that ends at `end` when there is one.
|
|
132
135
|
*/
|
|
133
136
|
function reading(document, start, quote, count, end) {
|
|
134
|
-
const emptyReference = count % 2 === 0 ? { value: '', length: count } : null;
|
|
135
137
|
if (end === null) {
|
|
136
|
-
|
|
138
|
+
// Nothing closes the run: an even one is the empty reference, which a
|
|
139
|
+
// later closing run would still turn into one holding what follows.
|
|
140
|
+
return count % 2 === 0 ? { value: '', length: count, closed: false } : null;
|
|
137
141
|
}
|
|
142
|
+
const emptyReference =
|
|
143
|
+
count % 2 === 0 ? { value: '', length: count, closed: true } : null;
|
|
138
144
|
|
|
139
145
|
const parts = [];
|
|
140
146
|
let position = start + count;
|
|
@@ -154,7 +160,7 @@ function reading(document, start, quote, count, end) {
|
|
|
154
160
|
if (emptyReference !== null && !isSubstantiveBody(value)) {
|
|
155
161
|
return emptyReference;
|
|
156
162
|
}
|
|
157
|
-
return { value, length: end - start };
|
|
163
|
+
return { value, length: end - start, closed: true };
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
/** The number of `quote` delimiters in a row from `start` of `text`. */
|