links-notation 0.27.1 → 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.
@@ -1,4 +1,4 @@
1
- // @generated by Peggy 5.1.0.
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 literalEscape(s) {
65
+ function escape(s, special) {
66
66
  return unicodeEscape(s
67
- .replace(/\\/g, "\\\\")
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 unicodeEscape(s
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);
@@ -224,7 +211,7 @@ function peg$parse(input, options) {
224
211
  }
225
212
  function peg$f10() { unreadableLines.add(lineKey(offset())); return false; }
226
213
  function peg$f11(l) { return l; }
227
- function peg$f12(i) { return { id: i }; }
214
+ function peg$f12(r) { return { id: r.value, rawId: r.raw }; }
228
215
  function peg$f13(g, rest) {
229
216
  return rest === null ? g : { values: [g].concat(rest) };
230
217
  }
@@ -243,18 +230,22 @@ function peg$parse(input, options) {
243
230
  function peg$f23() { return location(); }
244
231
  function peg$f24(value) { return value; }
245
232
  function peg$f25(list) { return list; }
246
- function peg$f26(id, v) { return { id: id, values: v }; }
233
+ function peg$f26(id, v) { return { id: id.value, rawId: id.raw, values: v }; }
247
234
  function peg$f27(v) { return { values: v }; }
248
- function peg$f28(id) { return { id: id, values: [] }; }
249
- function peg$f29() {
235
+ function peg$f28(id) { return { id: id.value, rawId: id.raw, values: [] }; }
236
+ function peg$f29(value) {
237
+ const { start, end } = range();
238
+ return { value: value, raw: source.slice(start, end) };
239
+ }
240
+ function peg$f30() {
250
241
  return hasReferenceLiteralPrefix(input, offset());
251
242
  }
252
- function peg$f30(literal) {
243
+ function peg$f31(literal) {
253
244
  return decodeReferenceLiteral(literal);
254
245
  }
255
- function peg$f31() { return !hasReferenceLiteralPrefix(input, offset()); }
256
- function peg$f32(chars) { return chars.join(''); }
257
- function peg$f33() {
246
+ function peg$f32() { return !hasReferenceLiteralPrefix(input, offset()); }
247
+ function peg$f33(chars) { return chars.join(''); }
248
+ function peg$f34() {
258
249
  const pos = offset();
259
250
  const result = parseQuotedStringAt(input, pos, '"');
260
251
  if (result) {
@@ -264,11 +255,11 @@ function peg$parse(input, options) {
264
255
  }
265
256
  return false;
266
257
  }
267
- function peg$f34(chars) { return parsedValue; }
268
- function peg$f35(c, cs) { return [c].concat(cs).join(''); }
269
- function peg$f36() { return parsedLength > 1 && (parsedLength--, true); }
270
- function peg$f37(c) { return c; }
271
- function peg$f38() {
258
+ function peg$f35(chars) { return parsedValue; }
259
+ function peg$f36(c, cs) { return [c].concat(cs).join(''); }
260
+ function peg$f37() { return parsedLength > 1 && (parsedLength--, true); }
261
+ function peg$f38(c) { return c; }
262
+ function peg$f39() {
272
263
  const pos = offset();
273
264
  const result = parseQuotedStringAt(input, pos, "'");
274
265
  if (result) {
@@ -278,11 +269,11 @@ function peg$parse(input, options) {
278
269
  }
279
270
  return false;
280
271
  }
281
- function peg$f39(chars) { return parsedValue; }
282
- function peg$f40(c, cs) { return [c].concat(cs).join(''); }
283
- function peg$f41() { return parsedLength > 1 && (parsedLength--, true); }
284
- function peg$f42(c) { return c; }
285
- function peg$f43() {
272
+ function peg$f40(chars) { return parsedValue; }
273
+ function peg$f41(c, cs) { return [c].concat(cs).join(''); }
274
+ function peg$f42() { return parsedLength > 1 && (parsedLength--, true); }
275
+ function peg$f43(c) { return c; }
276
+ function peg$f44() {
286
277
  const pos = offset();
287
278
  const result = parseQuotedStringAt(input, pos, '`');
288
279
  if (result) {
@@ -292,16 +283,16 @@ function peg$parse(input, options) {
292
283
  }
293
284
  return false;
294
285
  }
295
- function peg$f44(chars) { return parsedValue; }
296
- function peg$f45(c, cs) { return [c].concat(cs).join(''); }
297
- function peg$f46() { return parsedLength > 1 && (parsedLength--, true); }
298
- function peg$f47(c) { return c; }
299
- function peg$f48() { return indentationStack.slice(); }
300
- function peg$f49(spaces) { setBaseIndentation(spaces); }
301
- function peg$f50(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
302
- function peg$f51(spaces) { pushIndentation(spaces); }
303
- function peg$f52(spaces) { return checkIndentation(spaces); }
304
- function peg$f53() { return isInsideNestedContext(); }
286
+ function peg$f45(chars) { return parsedValue; }
287
+ function peg$f46(c, cs) { return [c].concat(cs).join(''); }
288
+ function peg$f47() { return parsedLength > 1 && (parsedLength--, true); }
289
+ function peg$f48(c) { return c; }
290
+ function peg$f49() { return indentationStack.slice(); }
291
+ function peg$f50(spaces) { setBaseIndentation(spaces); }
292
+ function peg$f51(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
293
+ function peg$f52(spaces) { pushIndentation(spaces); }
294
+ function peg$f53(spaces) { return checkIndentation(spaces); }
295
+ function peg$f54() { return isInsideNestedContext(); }
305
296
  let peg$currPos = options.peg$currPos | 0;
306
297
  let peg$savedPos = peg$currPos;
307
298
  const peg$posDetailsCache = [{ line: 1, column: 1 }];
@@ -310,6 +301,7 @@ function peg$parse(input, options) {
310
301
  let peg$silentFails = options.peg$silentFails | 0;
311
302
 
312
303
  let peg$result;
304
+ let peg$charCode;
313
305
 
314
306
  if (options.startRule) {
315
307
  if (!(options.startRule in peg$startRuleFunctions)) {
@@ -536,62 +528,22 @@ function peg$parse(input, options) {
536
528
  let s0, s1, s2, s3;
537
529
 
538
530
  s0 = [];
539
- s1 = peg$currPos;
540
- s2 = [];
541
- s3 = input.charAt(peg$currPos);
542
- if (peg$r0.test(s3)) {
543
- peg$currPos++;
544
- } else {
545
- s3 = peg$FAILED;
546
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
547
- }
548
- while (s3 !== peg$FAILED) {
549
- s2.push(s3);
550
- s3 = input.charAt(peg$currPos);
551
- if (peg$r0.test(s3)) {
552
- peg$currPos++;
553
- } else {
554
- s3 = peg$FAILED;
555
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
556
- }
557
- }
558
- s3 = input.charAt(peg$currPos);
559
- if (peg$r1.test(s3)) {
560
- peg$currPos++;
561
- } else {
562
- s3 = peg$FAILED;
563
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
564
- }
565
- if (s3 !== peg$FAILED) {
566
- s2 = [s2, s3];
567
- s1 = s2;
568
- } else {
569
- peg$currPos = s1;
570
- s1 = peg$FAILED;
571
- }
572
- while (s1 !== peg$FAILED) {
573
- s0.push(s1);
531
+ for (;;) {
574
532
  s1 = peg$currPos;
575
533
  s2 = [];
576
- s3 = input.charAt(peg$currPos);
577
- if (peg$r0.test(s3)) {
578
- peg$currPos++;
579
- } else {
580
- s3 = peg$FAILED;
581
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
582
- }
583
- while (s3 !== peg$FAILED) {
584
- s2.push(s3);
534
+ for (;;) {
585
535
  s3 = input.charAt(peg$currPos);
586
- if (peg$r0.test(s3)) {
536
+ if ((peg$charCode = s3.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
587
537
  peg$currPos++;
588
538
  } else {
589
539
  s3 = peg$FAILED;
590
540
  if (peg$silentFails === 0) { peg$fail(peg$e0); }
591
541
  }
542
+ if (s3 === peg$FAILED) { break; }
543
+ s2.push(s3);
592
544
  }
593
545
  s3 = input.charAt(peg$currPos);
594
- if (peg$r1.test(s3)) {
546
+ if ((peg$charCode = s3.charCodeAt(0), peg$charCode === 13 || peg$charCode === 10)) {
595
547
  peg$currPos++;
596
548
  } else {
597
549
  s3 = peg$FAILED;
@@ -604,6 +556,8 @@ function peg$parse(input, options) {
604
556
  peg$currPos = s1;
605
557
  s1 = peg$FAILED;
606
558
  }
559
+ if (s1 === peg$FAILED) { break; }
560
+ s0.push(s1);
607
561
  }
608
562
 
609
563
  return s0;
@@ -616,10 +570,10 @@ function peg$parse(input, options) {
616
570
  s1 = peg$parsefirstLine();
617
571
  if (s1 !== peg$FAILED) {
618
572
  s2 = [];
619
- s3 = peg$parseline();
620
- while (s3 !== peg$FAILED) {
621
- s2.push(s3);
573
+ for (;;) {
622
574
  s3 = peg$parseline();
575
+ if (s3 === peg$FAILED) { break; }
576
+ s2.push(s3);
623
577
  }
624
578
  peg$savedPos = s0;
625
579
  s0 = peg$f4(s1, s2);
@@ -886,10 +840,10 @@ function peg$parse(input, options) {
886
840
  if (s0 === peg$FAILED) {
887
841
  s0 = peg$currPos;
888
842
  s1 = [];
889
- s2 = peg$parsesingleLineValueAndWhitespace();
890
- while (s2 !== peg$FAILED) {
891
- s1.push(s2);
843
+ for (;;) {
892
844
  s2 = peg$parsesingleLineValueAndWhitespace();
845
+ if (s2 === peg$FAILED) { break; }
846
+ s1.push(s2);
893
847
  }
894
848
  s2 = peg$parseeol();
895
849
  if (s2 !== peg$FAILED) {
@@ -1114,13 +1068,12 @@ function peg$parse(input, options) {
1114
1068
 
1115
1069
  s0 = peg$currPos;
1116
1070
  s1 = [];
1117
- s2 = peg$parsesingleLineValueAndWhitespace();
1118
- if (s2 !== peg$FAILED) {
1119
- while (s2 !== peg$FAILED) {
1120
- s1.push(s2);
1121
- s2 = peg$parsesingleLineValueAndWhitespace();
1122
- }
1123
- } else {
1071
+ for (;;) {
1072
+ s2 = peg$parsesingleLineValueAndWhitespace();
1073
+ if (s2 === peg$FAILED) { break; }
1074
+ s1.push(s2);
1075
+ }
1076
+ if (s1.length < 1) {
1124
1077
  s1 = peg$FAILED;
1125
1078
  }
1126
1079
  if (s1 !== peg$FAILED) {
@@ -1218,6 +1171,20 @@ function peg$parse(input, options) {
1218
1171
  }
1219
1172
 
1220
1173
  function peg$parsereference() {
1174
+ let s0, s1;
1175
+
1176
+ s0 = peg$currPos;
1177
+ s1 = peg$parsereferenceValue();
1178
+ if (s1 !== peg$FAILED) {
1179
+ peg$savedPos = s0;
1180
+ s1 = peg$f29(s1);
1181
+ }
1182
+ s0 = s1;
1183
+
1184
+ return s0;
1185
+ }
1186
+
1187
+ function peg$parsereferenceValue() {
1221
1188
  let s0;
1222
1189
 
1223
1190
  s0 = peg$parsereferenceLiteral();
@@ -1253,7 +1220,7 @@ function peg$parse(input, options) {
1253
1220
  }
1254
1221
  if (s1 !== peg$FAILED) {
1255
1222
  peg$savedPos = peg$currPos;
1256
- s2 = peg$f29();
1223
+ s2 = peg$f30();
1257
1224
  if (s2) {
1258
1225
  s2 = undefined;
1259
1226
  } else {
@@ -1271,25 +1238,18 @@ function peg$parse(input, options) {
1271
1238
  }
1272
1239
  if (s5 !== peg$FAILED) {
1273
1240
  s6 = [];
1274
- s7 = input.charAt(peg$currPos);
1275
- if (peg$r2.test(s7)) {
1276
- peg$currPos++;
1277
- } else {
1278
- s7 = peg$FAILED;
1279
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1280
- }
1281
- if (s7 !== peg$FAILED) {
1282
- while (s7 !== peg$FAILED) {
1283
- s6.push(s7);
1284
- s7 = input.charAt(peg$currPos);
1285
- if (peg$r2.test(s7)) {
1286
- peg$currPos++;
1287
- } else {
1288
- s7 = peg$FAILED;
1289
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1290
- }
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); }
1291
1248
  }
1292
- } else {
1249
+ if (s7 === peg$FAILED) { break; }
1250
+ s6.push(s7);
1251
+ }
1252
+ if (s6.length < 1) {
1293
1253
  s6 = peg$FAILED;
1294
1254
  }
1295
1255
  if (s6 !== peg$FAILED) {
@@ -1302,22 +1262,16 @@ function peg$parse(input, options) {
1302
1262
  }
1303
1263
  if (s7 !== peg$FAILED) {
1304
1264
  s8 = [];
1305
- s9 = input.charAt(peg$currPos);
1306
- if (peg$r3.test(s9)) {
1307
- peg$currPos++;
1308
- } else {
1309
- s9 = peg$FAILED;
1310
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1311
- }
1312
- while (s9 !== peg$FAILED) {
1313
- s8.push(s9);
1265
+ for (;;) {
1314
1266
  s9 = input.charAt(peg$currPos);
1315
- if (peg$r3.test(s9)) {
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)) {
1316
1268
  peg$currPos++;
1317
1269
  } else {
1318
1270
  s9 = peg$FAILED;
1319
1271
  if (peg$silentFails === 0) { peg$fail(peg$e9); }
1320
1272
  }
1273
+ if (s9 === peg$FAILED) { break; }
1274
+ s8.push(s9);
1321
1275
  }
1322
1276
  if (input.charCodeAt(peg$currPos) === 125) {
1323
1277
  s9 = peg$c5;
@@ -1352,7 +1306,7 @@ function peg$parse(input, options) {
1352
1306
  }
1353
1307
  if (s3 !== peg$FAILED) {
1354
1308
  peg$savedPos = s0;
1355
- s0 = peg$f30(s3);
1309
+ s0 = peg$f31(s3);
1356
1310
  } else {
1357
1311
  peg$currPos = s0;
1358
1312
  s0 = peg$FAILED;
@@ -1374,7 +1328,7 @@ function peg$parse(input, options) {
1374
1328
 
1375
1329
  s0 = peg$currPos;
1376
1330
  peg$savedPos = peg$currPos;
1377
- s1 = peg$f31();
1331
+ s1 = peg$f32();
1378
1332
  if (s1) {
1379
1333
  s1 = undefined;
1380
1334
  } else {
@@ -1382,18 +1336,17 @@ function peg$parse(input, options) {
1382
1336
  }
1383
1337
  if (s1 !== peg$FAILED) {
1384
1338
  s2 = [];
1385
- s3 = peg$parsereferenceSymbol();
1386
- if (s3 !== peg$FAILED) {
1387
- while (s3 !== peg$FAILED) {
1388
- s2.push(s3);
1389
- s3 = peg$parsereferenceSymbol();
1390
- }
1391
- } else {
1339
+ for (;;) {
1340
+ s3 = peg$parsereferenceSymbol();
1341
+ if (s3 === peg$FAILED) { break; }
1342
+ s2.push(s3);
1343
+ }
1344
+ if (s2.length < 1) {
1392
1345
  s2 = peg$FAILED;
1393
1346
  }
1394
1347
  if (s2 !== peg$FAILED) {
1395
1348
  peg$savedPos = s0;
1396
- s0 = peg$f32(s2);
1349
+ s0 = peg$f33(s2);
1397
1350
  } else {
1398
1351
  peg$currPos = s0;
1399
1352
  s0 = peg$FAILED;
@@ -1442,7 +1395,7 @@ function peg$parse(input, options) {
1442
1395
  }
1443
1396
  if (s1 !== peg$FAILED) {
1444
1397
  peg$savedPos = peg$currPos;
1445
- s2 = peg$f33();
1398
+ s2 = peg$f34();
1446
1399
  if (s2) {
1447
1400
  s2 = undefined;
1448
1401
  } else {
@@ -1452,7 +1405,7 @@ function peg$parse(input, options) {
1452
1405
  s3 = peg$parseconsumeDouble();
1453
1406
  if (s3 !== peg$FAILED) {
1454
1407
  peg$savedPos = s0;
1455
- s0 = peg$f34(s3);
1408
+ s0 = peg$f35(s3);
1456
1409
  } else {
1457
1410
  peg$currPos = s0;
1458
1411
  s0 = peg$FAILED;
@@ -1482,13 +1435,13 @@ function peg$parse(input, options) {
1482
1435
  }
1483
1436
  if (s1 !== peg$FAILED) {
1484
1437
  s2 = [];
1485
- s3 = peg$parseconsumeDoubleMore();
1486
- while (s3 !== peg$FAILED) {
1487
- s2.push(s3);
1438
+ for (;;) {
1488
1439
  s3 = peg$parseconsumeDoubleMore();
1440
+ if (s3 === peg$FAILED) { break; }
1441
+ s2.push(s3);
1489
1442
  }
1490
1443
  peg$savedPos = s0;
1491
- s0 = peg$f35(s1, s2);
1444
+ s0 = peg$f36(s1, s2);
1492
1445
  } else {
1493
1446
  peg$currPos = s0;
1494
1447
  s0 = peg$FAILED;
@@ -1502,7 +1455,7 @@ function peg$parse(input, options) {
1502
1455
 
1503
1456
  s0 = peg$currPos;
1504
1457
  peg$savedPos = peg$currPos;
1505
- s1 = peg$f36();
1458
+ s1 = peg$f37();
1506
1459
  if (s1) {
1507
1460
  s1 = undefined;
1508
1461
  } else {
@@ -1518,7 +1471,7 @@ function peg$parse(input, options) {
1518
1471
  }
1519
1472
  if (s2 !== peg$FAILED) {
1520
1473
  peg$savedPos = s0;
1521
- s0 = peg$f37(s2);
1474
+ s0 = peg$f38(s2);
1522
1475
  } else {
1523
1476
  peg$currPos = s0;
1524
1477
  s0 = peg$FAILED;
@@ -1553,7 +1506,7 @@ function peg$parse(input, options) {
1553
1506
  }
1554
1507
  if (s1 !== peg$FAILED) {
1555
1508
  peg$savedPos = peg$currPos;
1556
- s2 = peg$f38();
1509
+ s2 = peg$f39();
1557
1510
  if (s2) {
1558
1511
  s2 = undefined;
1559
1512
  } else {
@@ -1563,7 +1516,7 @@ function peg$parse(input, options) {
1563
1516
  s3 = peg$parseconsumeSingle();
1564
1517
  if (s3 !== peg$FAILED) {
1565
1518
  peg$savedPos = s0;
1566
- s0 = peg$f39(s3);
1519
+ s0 = peg$f40(s3);
1567
1520
  } else {
1568
1521
  peg$currPos = s0;
1569
1522
  s0 = peg$FAILED;
@@ -1593,13 +1546,13 @@ function peg$parse(input, options) {
1593
1546
  }
1594
1547
  if (s1 !== peg$FAILED) {
1595
1548
  s2 = [];
1596
- s3 = peg$parseconsumeSingleMore();
1597
- while (s3 !== peg$FAILED) {
1598
- s2.push(s3);
1549
+ for (;;) {
1599
1550
  s3 = peg$parseconsumeSingleMore();
1551
+ if (s3 === peg$FAILED) { break; }
1552
+ s2.push(s3);
1600
1553
  }
1601
1554
  peg$savedPos = s0;
1602
- s0 = peg$f40(s1, s2);
1555
+ s0 = peg$f41(s1, s2);
1603
1556
  } else {
1604
1557
  peg$currPos = s0;
1605
1558
  s0 = peg$FAILED;
@@ -1613,7 +1566,7 @@ function peg$parse(input, options) {
1613
1566
 
1614
1567
  s0 = peg$currPos;
1615
1568
  peg$savedPos = peg$currPos;
1616
- s1 = peg$f41();
1569
+ s1 = peg$f42();
1617
1570
  if (s1) {
1618
1571
  s1 = undefined;
1619
1572
  } else {
@@ -1629,7 +1582,7 @@ function peg$parse(input, options) {
1629
1582
  }
1630
1583
  if (s2 !== peg$FAILED) {
1631
1584
  peg$savedPos = s0;
1632
- s0 = peg$f42(s2);
1585
+ s0 = peg$f43(s2);
1633
1586
  } else {
1634
1587
  peg$currPos = s0;
1635
1588
  s0 = peg$FAILED;
@@ -1664,7 +1617,7 @@ function peg$parse(input, options) {
1664
1617
  }
1665
1618
  if (s1 !== peg$FAILED) {
1666
1619
  peg$savedPos = peg$currPos;
1667
- s2 = peg$f43();
1620
+ s2 = peg$f44();
1668
1621
  if (s2) {
1669
1622
  s2 = undefined;
1670
1623
  } else {
@@ -1674,7 +1627,7 @@ function peg$parse(input, options) {
1674
1627
  s3 = peg$parseconsumeBacktick();
1675
1628
  if (s3 !== peg$FAILED) {
1676
1629
  peg$savedPos = s0;
1677
- s0 = peg$f44(s3);
1630
+ s0 = peg$f45(s3);
1678
1631
  } else {
1679
1632
  peg$currPos = s0;
1680
1633
  s0 = peg$FAILED;
@@ -1704,13 +1657,13 @@ function peg$parse(input, options) {
1704
1657
  }
1705
1658
  if (s1 !== peg$FAILED) {
1706
1659
  s2 = [];
1707
- s3 = peg$parseconsumeBacktickMore();
1708
- while (s3 !== peg$FAILED) {
1709
- s2.push(s3);
1660
+ for (;;) {
1710
1661
  s3 = peg$parseconsumeBacktickMore();
1662
+ if (s3 === peg$FAILED) { break; }
1663
+ s2.push(s3);
1711
1664
  }
1712
1665
  peg$savedPos = s0;
1713
- s0 = peg$f45(s1, s2);
1666
+ s0 = peg$f46(s1, s2);
1714
1667
  } else {
1715
1668
  peg$currPos = s0;
1716
1669
  s0 = peg$FAILED;
@@ -1724,7 +1677,7 @@ function peg$parse(input, options) {
1724
1677
 
1725
1678
  s0 = peg$currPos;
1726
1679
  peg$savedPos = peg$currPos;
1727
- s1 = peg$f46();
1680
+ s1 = peg$f47();
1728
1681
  if (s1) {
1729
1682
  s1 = undefined;
1730
1683
  } else {
@@ -1740,7 +1693,7 @@ function peg$parse(input, options) {
1740
1693
  }
1741
1694
  if (s2 !== peg$FAILED) {
1742
1695
  peg$savedPos = s0;
1743
- s0 = peg$f47(s2);
1696
+ s0 = peg$f48(s2);
1744
1697
  } else {
1745
1698
  peg$currPos = s0;
1746
1699
  s0 = peg$FAILED;
@@ -1759,7 +1712,7 @@ function peg$parse(input, options) {
1759
1712
  s0 = peg$currPos;
1760
1713
  s1 = '';
1761
1714
  peg$savedPos = s0;
1762
- s1 = peg$f48();
1715
+ s1 = peg$f49();
1763
1716
  s0 = s1;
1764
1717
 
1765
1718
  return s0;
@@ -1770,15 +1723,7 @@ function peg$parse(input, options) {
1770
1723
 
1771
1724
  s0 = peg$currPos;
1772
1725
  s1 = [];
1773
- if (input.charCodeAt(peg$currPos) === 32) {
1774
- s2 = peg$c9;
1775
- peg$currPos++;
1776
- } else {
1777
- s2 = peg$FAILED;
1778
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
1779
- }
1780
- while (s2 !== peg$FAILED) {
1781
- s1.push(s2);
1726
+ for (;;) {
1782
1727
  if (input.charCodeAt(peg$currPos) === 32) {
1783
1728
  s2 = peg$c9;
1784
1729
  peg$currPos++;
@@ -1786,9 +1731,11 @@ function peg$parse(input, options) {
1786
1731
  s2 = peg$FAILED;
1787
1732
  if (peg$silentFails === 0) { peg$fail(peg$e14); }
1788
1733
  }
1734
+ if (s2 === peg$FAILED) { break; }
1735
+ s1.push(s2);
1789
1736
  }
1790
1737
  peg$savedPos = s0;
1791
- s1 = peg$f49(s1);
1738
+ s1 = peg$f50(s1);
1792
1739
  s0 = s1;
1793
1740
 
1794
1741
  return s0;
@@ -1799,15 +1746,7 @@ function peg$parse(input, options) {
1799
1746
 
1800
1747
  s0 = peg$currPos;
1801
1748
  s1 = [];
1802
- if (input.charCodeAt(peg$currPos) === 32) {
1803
- s2 = peg$c9;
1804
- peg$currPos++;
1805
- } else {
1806
- s2 = peg$FAILED;
1807
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
1808
- }
1809
- while (s2 !== peg$FAILED) {
1810
- s1.push(s2);
1749
+ for (;;) {
1811
1750
  if (input.charCodeAt(peg$currPos) === 32) {
1812
1751
  s2 = peg$c9;
1813
1752
  peg$currPos++;
@@ -1815,9 +1754,11 @@ function peg$parse(input, options) {
1815
1754
  s2 = peg$FAILED;
1816
1755
  if (peg$silentFails === 0) { peg$fail(peg$e14); }
1817
1756
  }
1757
+ if (s2 === peg$FAILED) { break; }
1758
+ s1.push(s2);
1818
1759
  }
1819
1760
  peg$savedPos = peg$currPos;
1820
- s2 = peg$f50(s1);
1761
+ s2 = peg$f51(s1);
1821
1762
  if (s2) {
1822
1763
  s2 = undefined;
1823
1764
  } else {
@@ -1825,7 +1766,7 @@ function peg$parse(input, options) {
1825
1766
  }
1826
1767
  if (s2 !== peg$FAILED) {
1827
1768
  peg$savedPos = s0;
1828
- s0 = peg$f51(s1);
1769
+ s0 = peg$f52(s1);
1829
1770
  } else {
1830
1771
  peg$currPos = s0;
1831
1772
  s0 = peg$FAILED;
@@ -1839,15 +1780,7 @@ function peg$parse(input, options) {
1839
1780
 
1840
1781
  s0 = peg$currPos;
1841
1782
  s1 = [];
1842
- if (input.charCodeAt(peg$currPos) === 32) {
1843
- s2 = peg$c9;
1844
- peg$currPos++;
1845
- } else {
1846
- s2 = peg$FAILED;
1847
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
1848
- }
1849
- while (s2 !== peg$FAILED) {
1850
- s1.push(s2);
1783
+ for (;;) {
1851
1784
  if (input.charCodeAt(peg$currPos) === 32) {
1852
1785
  s2 = peg$c9;
1853
1786
  peg$currPos++;
@@ -1855,9 +1788,11 @@ function peg$parse(input, options) {
1855
1788
  s2 = peg$FAILED;
1856
1789
  if (peg$silentFails === 0) { peg$fail(peg$e14); }
1857
1790
  }
1791
+ if (s2 === peg$FAILED) { break; }
1792
+ s1.push(s2);
1858
1793
  }
1859
1794
  peg$savedPos = peg$currPos;
1860
- s2 = peg$f52(s1);
1795
+ s2 = peg$f53(s1);
1861
1796
  if (s2) {
1862
1797
  s2 = undefined;
1863
1798
  } else {
@@ -1902,132 +1837,53 @@ function peg$parse(input, options) {
1902
1837
 
1903
1838
  s0 = peg$currPos;
1904
1839
  s1 = [];
1905
- s2 = input.charAt(peg$currPos);
1906
- if (peg$r1.test(s2)) {
1907
- peg$currPos++;
1908
- } else {
1909
- s2 = peg$FAILED;
1910
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
1911
- }
1912
- if (s2 !== peg$FAILED) {
1913
- while (s2 !== peg$FAILED) {
1914
- s1.push(s2);
1915
- s2 = input.charAt(peg$currPos);
1916
- if (peg$r1.test(s2)) {
1917
- peg$currPos++;
1918
- } else {
1919
- s2 = peg$FAILED;
1920
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
1921
- }
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); }
1922
1847
  }
1923
- } else {
1848
+ if (s2 === peg$FAILED) { break; }
1849
+ s1.push(s2);
1850
+ }
1851
+ if (s1.length < 1) {
1924
1852
  s1 = peg$FAILED;
1925
1853
  }
1926
1854
  if (s1 !== peg$FAILED) {
1927
1855
  s2 = [];
1928
- s3 = peg$currPos;
1929
- s4 = [];
1930
- s5 = input.charAt(peg$currPos);
1931
- if (peg$r0.test(s5)) {
1932
- peg$currPos++;
1933
- } else {
1934
- s5 = peg$FAILED;
1935
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1936
- }
1937
- if (s5 !== peg$FAILED) {
1938
- while (s5 !== peg$FAILED) {
1939
- s4.push(s5);
1856
+ for (;;) {
1857
+ s3 = peg$currPos;
1858
+ s4 = [];
1859
+ for (;;) {
1940
1860
  s5 = input.charAt(peg$currPos);
1941
- if (peg$r0.test(s5)) {
1861
+ if ((peg$charCode = s5.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
1942
1862
  peg$currPos++;
1943
1863
  } else {
1944
1864
  s5 = peg$FAILED;
1945
1865
  if (peg$silentFails === 0) { peg$fail(peg$e0); }
1946
1866
  }
1867
+ if (s5 === peg$FAILED) { break; }
1868
+ s4.push(s5);
1947
1869
  }
1948
- } else {
1949
- s4 = peg$FAILED;
1950
- }
1951
- if (s4 !== peg$FAILED) {
1952
- s5 = [];
1953
- s6 = input.charAt(peg$currPos);
1954
- if (peg$r1.test(s6)) {
1955
- peg$currPos++;
1956
- } else {
1957
- s6 = peg$FAILED;
1958
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
1870
+ if (s4.length < 1) {
1871
+ s4 = peg$FAILED;
1959
1872
  }
1960
- if (s6 !== peg$FAILED) {
1961
- while (s6 !== peg$FAILED) {
1962
- s5.push(s6);
1873
+ if (s4 !== peg$FAILED) {
1874
+ s5 = [];
1875
+ for (;;) {
1963
1876
  s6 = input.charAt(peg$currPos);
1964
- if (peg$r1.test(s6)) {
1877
+ if ((peg$charCode = s6.charCodeAt(0), peg$charCode === 13 || peg$charCode === 10)) {
1965
1878
  peg$currPos++;
1966
1879
  } else {
1967
1880
  s6 = peg$FAILED;
1968
1881
  if (peg$silentFails === 0) { peg$fail(peg$e1); }
1969
1882
  }
1883
+ if (s6 === peg$FAILED) { break; }
1884
+ s5.push(s6);
1970
1885
  }
1971
- } else {
1972
- s5 = peg$FAILED;
1973
- }
1974
- if (s5 !== peg$FAILED) {
1975
- s4 = [s4, s5];
1976
- s3 = s4;
1977
- } else {
1978
- peg$currPos = s3;
1979
- s3 = peg$FAILED;
1980
- }
1981
- } else {
1982
- peg$currPos = s3;
1983
- s3 = peg$FAILED;
1984
- }
1985
- while (s3 !== peg$FAILED) {
1986
- s2.push(s3);
1987
- s3 = peg$currPos;
1988
- s4 = [];
1989
- s5 = input.charAt(peg$currPos);
1990
- if (peg$r0.test(s5)) {
1991
- peg$currPos++;
1992
- } else {
1993
- s5 = peg$FAILED;
1994
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
1995
- }
1996
- if (s5 !== peg$FAILED) {
1997
- while (s5 !== peg$FAILED) {
1998
- s4.push(s5);
1999
- s5 = input.charAt(peg$currPos);
2000
- if (peg$r0.test(s5)) {
2001
- peg$currPos++;
2002
- } else {
2003
- s5 = peg$FAILED;
2004
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
2005
- }
2006
- }
2007
- } else {
2008
- s4 = peg$FAILED;
2009
- }
2010
- if (s4 !== peg$FAILED) {
2011
- s5 = [];
2012
- s6 = input.charAt(peg$currPos);
2013
- if (peg$r1.test(s6)) {
2014
- peg$currPos++;
2015
- } else {
2016
- s6 = peg$FAILED;
2017
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
2018
- }
2019
- if (s6 !== peg$FAILED) {
2020
- while (s6 !== peg$FAILED) {
2021
- s5.push(s6);
2022
- s6 = input.charAt(peg$currPos);
2023
- if (peg$r1.test(s6)) {
2024
- peg$currPos++;
2025
- } else {
2026
- s6 = peg$FAILED;
2027
- if (peg$silentFails === 0) { peg$fail(peg$e1); }
2028
- }
2029
- }
2030
- } else {
1886
+ if (s5.length < 1) {
2031
1887
  s5 = peg$FAILED;
2032
1888
  }
2033
1889
  if (s5 !== peg$FAILED) {
@@ -2041,6 +1897,8 @@ function peg$parse(input, options) {
2041
1897
  peg$currPos = s3;
2042
1898
  s3 = peg$FAILED;
2043
1899
  }
1900
+ if (s3 === peg$FAILED) { break; }
1901
+ s2.push(s3);
2044
1902
  }
2045
1903
  s1 = [s1, s2];
2046
1904
  s0 = s1;
@@ -2057,7 +1915,7 @@ function peg$parse(input, options) {
2057
1915
 
2058
1916
  s0 = peg$currPos;
2059
1917
  peg$savedPos = peg$currPos;
2060
- s1 = peg$f53();
1918
+ s1 = peg$f54();
2061
1919
  if (s1) {
2062
1920
  s1 = undefined;
2063
1921
  } else {
@@ -2122,22 +1980,16 @@ function peg$parse(input, options) {
2122
1980
  let s0, s1;
2123
1981
 
2124
1982
  s0 = [];
2125
- s1 = input.charAt(peg$currPos);
2126
- if (peg$r0.test(s1)) {
2127
- peg$currPos++;
2128
- } else {
2129
- s1 = peg$FAILED;
2130
- if (peg$silentFails === 0) { peg$fail(peg$e0); }
2131
- }
2132
- while (s1 !== peg$FAILED) {
2133
- s0.push(s1);
1983
+ for (;;) {
2134
1984
  s1 = input.charAt(peg$currPos);
2135
- if (peg$r0.test(s1)) {
1985
+ if ((peg$charCode = s1.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
2136
1986
  peg$currPos++;
2137
1987
  } else {
2138
1988
  s1 = peg$FAILED;
2139
1989
  if (peg$silentFails === 0) { peg$fail(peg$e0); }
2140
1990
  }
1991
+ if (s1 === peg$FAILED) { break; }
1992
+ s0.push(s1);
2141
1993
  }
2142
1994
 
2143
1995
  return s0;
@@ -2147,10 +1999,10 @@ function peg$parse(input, options) {
2147
1999
  let s0, s1;
2148
2000
 
2149
2001
  s0 = [];
2150
- s1 = peg$parsewhiteSpaceSymbol();
2151
- while (s1 !== peg$FAILED) {
2152
- s0.push(s1);
2002
+ for (;;) {
2153
2003
  s1 = peg$parsewhiteSpaceSymbol();
2004
+ if (s1 === peg$FAILED) { break; }
2005
+ s0.push(s1);
2154
2006
  }
2155
2007
 
2156
2008
  return s0;
@@ -2160,7 +2012,7 @@ function peg$parse(input, options) {
2160
2012
  let s0;
2161
2013
 
2162
2014
  s0 = input.charAt(peg$currPos);
2163
- if (peg$r4.test(s0)) {
2015
+ if ((peg$charCode = s0.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9 || peg$charCode === 10 || peg$charCode === 13)) {
2164
2016
  peg$currPos++;
2165
2017
  } else {
2166
2018
  s0 = peg$FAILED;
@@ -2174,7 +2026,7 @@ function peg$parse(input, options) {
2174
2026
  let s0;
2175
2027
 
2176
2028
  s0 = input.charAt(peg$currPos);
2177
- if (peg$r5.test(s0)) {
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)) {
2178
2030
  peg$currPos++;
2179
2031
  } else {
2180
2032
  s0 = peg$FAILED;
@@ -2197,6 +2049,8 @@ function peg$parse(input, options) {
2197
2049
  // until the stack overflows.
2198
2050
  let contextDepth = 0;
2199
2051
  const maxDepth = options.maxDepth ?? Infinity;
2052
+ // The document as the caller wrote it, comments included.
2053
+ const source = options.source ?? input;
2200
2054
  // Lines already found unreadable, keyed by where they start and whether they
2201
2055
  // are inside a parenthesised group. Reading a line depends on nothing else: a
2202
2056
  // group starts a fresh indentation context, and indentation only decides
@@ -2296,8 +2150,10 @@ function peg$parse(input, options) {
2296
2150
  }
2297
2151
 
2298
2152
  // Delimited references of this document, each read once however many
2299
- // alternatives ask for it (see quotes.js for how a reference is read)
2300
- const delimitedReferences = new DelimitedReferences(input);
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);
2301
2157
 
2302
2158
  // Universal procedural parser for N-quote strings (any N >= 1)
2303
2159
  // Parses from the given position in the input string