links-notation 0.23.0 → 0.24.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.
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
  import { DelimitedReferences } from './quotes.js';
8
+ import { decodeReferenceLiteral, hasReferenceLiteralPrefix } from './ReferenceLiteral.js';
8
9
 
9
10
  class peg$SyntaxError extends SyntaxError {
10
11
  constructor(message, expected, found, location) {
@@ -170,15 +171,20 @@ function peg$parse(input, options) {
170
171
  const peg$c0 = "(";
171
172
  const peg$c1 = ")";
172
173
  const peg$c2 = ":";
173
- const peg$c3 = "\"";
174
- const peg$c4 = "'";
175
- const peg$c5 = "`";
176
- const peg$c6 = " ";
174
+ const peg$c3 = "~";
175
+ const peg$c4 = "{";
176
+ const peg$c5 = "}";
177
+ const peg$c6 = "\"";
178
+ const peg$c7 = "'";
179
+ const peg$c8 = "`";
180
+ const peg$c9 = " ";
177
181
 
178
182
  const peg$r0 = /^[ \t]/;
179
183
  const peg$r1 = /^[\r\n]/;
180
- const peg$r2 = /^[ \t\n\r]/;
181
- const peg$r3 = /^[^ \t\n\r(:)]/;
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(:)]/;
182
188
 
183
189
  const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
184
190
  const peg$e1 = peg$classExpectation(["\r", "\n"], false, false, false);
@@ -186,12 +192,17 @@ function peg$parse(input, options) {
186
192
  const peg$e3 = peg$literalExpectation("(", false);
187
193
  const peg$e4 = peg$literalExpectation(")", false);
188
194
  const peg$e5 = peg$literalExpectation(":", false);
189
- const peg$e6 = peg$literalExpectation("\"", false);
190
- const peg$e7 = peg$literalExpectation("'", false);
191
- const peg$e8 = peg$literalExpectation("`", false);
192
- const peg$e9 = peg$literalExpectation(" ", false);
193
- const peg$e10 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false);
194
- const peg$e11 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
195
+ const peg$e6 = peg$literalExpectation("~", false);
196
+ const peg$e7 = peg$classExpectation([["0", "9"]], false, false, false);
197
+ const peg$e8 = peg$literalExpectation("{", false);
198
+ const peg$e9 = peg$classExpectation(["}", " ", "\t", "\r", "\n", "(", ")"], true, false, false);
199
+ const peg$e10 = peg$literalExpectation("}", false);
200
+ const peg$e11 = peg$literalExpectation("\"", false);
201
+ const peg$e12 = peg$literalExpectation("'", false);
202
+ const peg$e13 = peg$literalExpectation("`", false);
203
+ const peg$e14 = peg$literalExpectation(" ", false);
204
+ const peg$e15 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false);
205
+ const peg$e16 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
195
206
 
196
207
  function peg$f0() { return resetState(); }
197
208
  function peg$f1(links) { return links; }
@@ -235,8 +246,15 @@ function peg$parse(input, options) {
235
246
  function peg$f26(id, v) { return { id: id, values: v }; }
236
247
  function peg$f27(v) { return { values: v }; }
237
248
  function peg$f28(id) { return { id: id, values: [] }; }
238
- function peg$f29(chars) { return chars.join(''); }
239
- function peg$f30() {
249
+ function peg$f29() {
250
+ return hasReferenceLiteralPrefix(input, offset());
251
+ }
252
+ function peg$f30(literal) {
253
+ return decodeReferenceLiteral(literal);
254
+ }
255
+ function peg$f31() { return !hasReferenceLiteralPrefix(input, offset()); }
256
+ function peg$f32(chars) { return chars.join(''); }
257
+ function peg$f33() {
240
258
  const pos = offset();
241
259
  const result = parseQuotedStringAt(input, pos, '"');
242
260
  if (result) {
@@ -246,11 +264,11 @@ function peg$parse(input, options) {
246
264
  }
247
265
  return false;
248
266
  }
249
- function peg$f31(chars) { return parsedValue; }
250
- function peg$f32(c, cs) { return [c].concat(cs).join(''); }
251
- function peg$f33() { return parsedLength > 1 && (parsedLength--, true); }
252
- function peg$f34(c) { return c; }
253
- function peg$f35() {
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() {
254
272
  const pos = offset();
255
273
  const result = parseQuotedStringAt(input, pos, "'");
256
274
  if (result) {
@@ -260,11 +278,11 @@ function peg$parse(input, options) {
260
278
  }
261
279
  return false;
262
280
  }
263
- function peg$f36(chars) { return parsedValue; }
264
- function peg$f37(c, cs) { return [c].concat(cs).join(''); }
265
- function peg$f38() { return parsedLength > 1 && (parsedLength--, true); }
266
- function peg$f39(c) { return c; }
267
- function peg$f40() {
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() {
268
286
  const pos = offset();
269
287
  const result = parseQuotedStringAt(input, pos, '`');
270
288
  if (result) {
@@ -274,16 +292,16 @@ function peg$parse(input, options) {
274
292
  }
275
293
  return false;
276
294
  }
277
- function peg$f41(chars) { return parsedValue; }
278
- function peg$f42(c, cs) { return [c].concat(cs).join(''); }
279
- function peg$f43() { return parsedLength > 1 && (parsedLength--, true); }
280
- function peg$f44(c) { return c; }
281
- function peg$f45() { return indentationStack.slice(); }
282
- function peg$f46(spaces) { setBaseIndentation(spaces); }
283
- function peg$f47(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
284
- function peg$f48(spaces) { pushIndentation(spaces); }
285
- function peg$f49(spaces) { return checkIndentation(spaces); }
286
- function peg$f50() { return isInsideNestedContext(); }
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(); }
287
305
  let peg$currPos = options.peg$currPos | 0;
288
306
  let peg$savedPos = peg$currPos;
289
307
  const peg$posDetailsCache = [{ line: 1, column: 1 }];
@@ -1202,33 +1220,188 @@ function peg$parse(input, options) {
1202
1220
  function peg$parsereference() {
1203
1221
  let s0;
1204
1222
 
1205
- s0 = peg$parsequotedReference();
1223
+ s0 = peg$parsereferenceLiteral();
1206
1224
  if (s0 === peg$FAILED) {
1207
- s0 = peg$parsesimpleReference();
1225
+ s0 = peg$parsequotedReference();
1226
+ if (s0 === peg$FAILED) {
1227
+ s0 = peg$parsesimpleReference();
1228
+ }
1208
1229
  }
1209
1230
 
1210
1231
  return s0;
1211
1232
  }
1212
1233
 
1213
- function peg$parsesimpleReference() {
1214
- let s0, s1, s2;
1234
+ function peg$parsereferenceLiteral() {
1235
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
1215
1236
 
1216
1237
  s0 = peg$currPos;
1217
- s1 = [];
1218
- s2 = peg$parsereferenceSymbol();
1238
+ s1 = peg$currPos;
1239
+ peg$silentFails++;
1240
+ if (input.charCodeAt(peg$currPos) === 126) {
1241
+ s2 = peg$c3;
1242
+ peg$currPos++;
1243
+ } else {
1244
+ s2 = peg$FAILED;
1245
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1246
+ }
1247
+ peg$silentFails--;
1219
1248
  if (s2 !== peg$FAILED) {
1220
- while (s2 !== peg$FAILED) {
1221
- s1.push(s2);
1222
- s2 = peg$parsereferenceSymbol();
1249
+ peg$currPos = s1;
1250
+ s1 = undefined;
1251
+ } else {
1252
+ s1 = peg$FAILED;
1253
+ }
1254
+ if (s1 !== peg$FAILED) {
1255
+ peg$savedPos = peg$currPos;
1256
+ s2 = peg$f29();
1257
+ if (s2) {
1258
+ s2 = undefined;
1259
+ } else {
1260
+ s2 = peg$FAILED;
1223
1261
  }
1262
+ if (s2 !== peg$FAILED) {
1263
+ s3 = peg$currPos;
1264
+ s4 = peg$currPos;
1265
+ if (input.charCodeAt(peg$currPos) === 126) {
1266
+ s5 = peg$c3;
1267
+ peg$currPos++;
1268
+ } else {
1269
+ s5 = peg$FAILED;
1270
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1271
+ }
1272
+ if (s5 !== peg$FAILED) {
1273
+ 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
+ }
1291
+ }
1292
+ } else {
1293
+ s6 = peg$FAILED;
1294
+ }
1295
+ if (s6 !== peg$FAILED) {
1296
+ if (input.charCodeAt(peg$currPos) === 123) {
1297
+ s7 = peg$c4;
1298
+ peg$currPos++;
1299
+ } else {
1300
+ s7 = peg$FAILED;
1301
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
1302
+ }
1303
+ if (s7 !== peg$FAILED) {
1304
+ 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);
1314
+ s9 = input.charAt(peg$currPos);
1315
+ if (peg$r3.test(s9)) {
1316
+ peg$currPos++;
1317
+ } else {
1318
+ s9 = peg$FAILED;
1319
+ if (peg$silentFails === 0) { peg$fail(peg$e9); }
1320
+ }
1321
+ }
1322
+ if (input.charCodeAt(peg$currPos) === 125) {
1323
+ s9 = peg$c5;
1324
+ peg$currPos++;
1325
+ } else {
1326
+ s9 = peg$FAILED;
1327
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
1328
+ }
1329
+ if (s9 !== peg$FAILED) {
1330
+ s5 = [s5, s6, s7, s8, s9];
1331
+ s4 = s5;
1332
+ } else {
1333
+ peg$currPos = s4;
1334
+ s4 = peg$FAILED;
1335
+ }
1336
+ } else {
1337
+ peg$currPos = s4;
1338
+ s4 = peg$FAILED;
1339
+ }
1340
+ } else {
1341
+ peg$currPos = s4;
1342
+ s4 = peg$FAILED;
1343
+ }
1344
+ } else {
1345
+ peg$currPos = s4;
1346
+ s4 = peg$FAILED;
1347
+ }
1348
+ if (s4 !== peg$FAILED) {
1349
+ s3 = input.substring(s3, peg$currPos);
1350
+ } else {
1351
+ s3 = s4;
1352
+ }
1353
+ if (s3 !== peg$FAILED) {
1354
+ peg$savedPos = s0;
1355
+ s0 = peg$f30(s3);
1356
+ } else {
1357
+ peg$currPos = s0;
1358
+ s0 = peg$FAILED;
1359
+ }
1360
+ } else {
1361
+ peg$currPos = s0;
1362
+ s0 = peg$FAILED;
1363
+ }
1364
+ } else {
1365
+ peg$currPos = s0;
1366
+ s0 = peg$FAILED;
1367
+ }
1368
+
1369
+ return s0;
1370
+ }
1371
+
1372
+ function peg$parsesimpleReference() {
1373
+ let s0, s1, s2, s3;
1374
+
1375
+ s0 = peg$currPos;
1376
+ peg$savedPos = peg$currPos;
1377
+ s1 = peg$f31();
1378
+ if (s1) {
1379
+ s1 = undefined;
1224
1380
  } else {
1225
1381
  s1 = peg$FAILED;
1226
1382
  }
1227
1383
  if (s1 !== peg$FAILED) {
1228
- peg$savedPos = s0;
1229
- s1 = peg$f29(s1);
1384
+ 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 {
1392
+ s2 = peg$FAILED;
1393
+ }
1394
+ if (s2 !== peg$FAILED) {
1395
+ peg$savedPos = s0;
1396
+ s0 = peg$f32(s2);
1397
+ } else {
1398
+ peg$currPos = s0;
1399
+ s0 = peg$FAILED;
1400
+ }
1401
+ } else {
1402
+ peg$currPos = s0;
1403
+ s0 = peg$FAILED;
1230
1404
  }
1231
- s0 = s1;
1232
1405
 
1233
1406
  return s0;
1234
1407
  }
@@ -1254,11 +1427,11 @@ function peg$parse(input, options) {
1254
1427
  s1 = peg$currPos;
1255
1428
  peg$silentFails++;
1256
1429
  if (input.charCodeAt(peg$currPos) === 34) {
1257
- s2 = peg$c3;
1430
+ s2 = peg$c6;
1258
1431
  peg$currPos++;
1259
1432
  } else {
1260
1433
  s2 = peg$FAILED;
1261
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1434
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
1262
1435
  }
1263
1436
  peg$silentFails--;
1264
1437
  if (s2 !== peg$FAILED) {
@@ -1269,7 +1442,7 @@ function peg$parse(input, options) {
1269
1442
  }
1270
1443
  if (s1 !== peg$FAILED) {
1271
1444
  peg$savedPos = peg$currPos;
1272
- s2 = peg$f30();
1445
+ s2 = peg$f33();
1273
1446
  if (s2) {
1274
1447
  s2 = undefined;
1275
1448
  } else {
@@ -1279,7 +1452,7 @@ function peg$parse(input, options) {
1279
1452
  s3 = peg$parseconsumeDouble();
1280
1453
  if (s3 !== peg$FAILED) {
1281
1454
  peg$savedPos = s0;
1282
- s0 = peg$f31(s3);
1455
+ s0 = peg$f34(s3);
1283
1456
  } else {
1284
1457
  peg$currPos = s0;
1285
1458
  s0 = peg$FAILED;
@@ -1315,7 +1488,7 @@ function peg$parse(input, options) {
1315
1488
  s3 = peg$parseconsumeDoubleMore();
1316
1489
  }
1317
1490
  peg$savedPos = s0;
1318
- s0 = peg$f32(s1, s2);
1491
+ s0 = peg$f35(s1, s2);
1319
1492
  } else {
1320
1493
  peg$currPos = s0;
1321
1494
  s0 = peg$FAILED;
@@ -1329,7 +1502,7 @@ function peg$parse(input, options) {
1329
1502
 
1330
1503
  s0 = peg$currPos;
1331
1504
  peg$savedPos = peg$currPos;
1332
- s1 = peg$f33();
1505
+ s1 = peg$f36();
1333
1506
  if (s1) {
1334
1507
  s1 = undefined;
1335
1508
  } else {
@@ -1345,7 +1518,7 @@ function peg$parse(input, options) {
1345
1518
  }
1346
1519
  if (s2 !== peg$FAILED) {
1347
1520
  peg$savedPos = s0;
1348
- s0 = peg$f34(s2);
1521
+ s0 = peg$f37(s2);
1349
1522
  } else {
1350
1523
  peg$currPos = s0;
1351
1524
  s0 = peg$FAILED;
@@ -1365,11 +1538,11 @@ function peg$parse(input, options) {
1365
1538
  s1 = peg$currPos;
1366
1539
  peg$silentFails++;
1367
1540
  if (input.charCodeAt(peg$currPos) === 39) {
1368
- s2 = peg$c4;
1541
+ s2 = peg$c7;
1369
1542
  peg$currPos++;
1370
1543
  } else {
1371
1544
  s2 = peg$FAILED;
1372
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1545
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
1373
1546
  }
1374
1547
  peg$silentFails--;
1375
1548
  if (s2 !== peg$FAILED) {
@@ -1380,7 +1553,7 @@ function peg$parse(input, options) {
1380
1553
  }
1381
1554
  if (s1 !== peg$FAILED) {
1382
1555
  peg$savedPos = peg$currPos;
1383
- s2 = peg$f35();
1556
+ s2 = peg$f38();
1384
1557
  if (s2) {
1385
1558
  s2 = undefined;
1386
1559
  } else {
@@ -1390,7 +1563,7 @@ function peg$parse(input, options) {
1390
1563
  s3 = peg$parseconsumeSingle();
1391
1564
  if (s3 !== peg$FAILED) {
1392
1565
  peg$savedPos = s0;
1393
- s0 = peg$f36(s3);
1566
+ s0 = peg$f39(s3);
1394
1567
  } else {
1395
1568
  peg$currPos = s0;
1396
1569
  s0 = peg$FAILED;
@@ -1426,7 +1599,7 @@ function peg$parse(input, options) {
1426
1599
  s3 = peg$parseconsumeSingleMore();
1427
1600
  }
1428
1601
  peg$savedPos = s0;
1429
- s0 = peg$f37(s1, s2);
1602
+ s0 = peg$f40(s1, s2);
1430
1603
  } else {
1431
1604
  peg$currPos = s0;
1432
1605
  s0 = peg$FAILED;
@@ -1440,7 +1613,7 @@ function peg$parse(input, options) {
1440
1613
 
1441
1614
  s0 = peg$currPos;
1442
1615
  peg$savedPos = peg$currPos;
1443
- s1 = peg$f38();
1616
+ s1 = peg$f41();
1444
1617
  if (s1) {
1445
1618
  s1 = undefined;
1446
1619
  } else {
@@ -1456,7 +1629,7 @@ function peg$parse(input, options) {
1456
1629
  }
1457
1630
  if (s2 !== peg$FAILED) {
1458
1631
  peg$savedPos = s0;
1459
- s0 = peg$f39(s2);
1632
+ s0 = peg$f42(s2);
1460
1633
  } else {
1461
1634
  peg$currPos = s0;
1462
1635
  s0 = peg$FAILED;
@@ -1476,11 +1649,11 @@ function peg$parse(input, options) {
1476
1649
  s1 = peg$currPos;
1477
1650
  peg$silentFails++;
1478
1651
  if (input.charCodeAt(peg$currPos) === 96) {
1479
- s2 = peg$c5;
1652
+ s2 = peg$c8;
1480
1653
  peg$currPos++;
1481
1654
  } else {
1482
1655
  s2 = peg$FAILED;
1483
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
1656
+ if (peg$silentFails === 0) { peg$fail(peg$e13); }
1484
1657
  }
1485
1658
  peg$silentFails--;
1486
1659
  if (s2 !== peg$FAILED) {
@@ -1491,7 +1664,7 @@ function peg$parse(input, options) {
1491
1664
  }
1492
1665
  if (s1 !== peg$FAILED) {
1493
1666
  peg$savedPos = peg$currPos;
1494
- s2 = peg$f40();
1667
+ s2 = peg$f43();
1495
1668
  if (s2) {
1496
1669
  s2 = undefined;
1497
1670
  } else {
@@ -1501,7 +1674,7 @@ function peg$parse(input, options) {
1501
1674
  s3 = peg$parseconsumeBacktick();
1502
1675
  if (s3 !== peg$FAILED) {
1503
1676
  peg$savedPos = s0;
1504
- s0 = peg$f41(s3);
1677
+ s0 = peg$f44(s3);
1505
1678
  } else {
1506
1679
  peg$currPos = s0;
1507
1680
  s0 = peg$FAILED;
@@ -1537,7 +1710,7 @@ function peg$parse(input, options) {
1537
1710
  s3 = peg$parseconsumeBacktickMore();
1538
1711
  }
1539
1712
  peg$savedPos = s0;
1540
- s0 = peg$f42(s1, s2);
1713
+ s0 = peg$f45(s1, s2);
1541
1714
  } else {
1542
1715
  peg$currPos = s0;
1543
1716
  s0 = peg$FAILED;
@@ -1551,7 +1724,7 @@ function peg$parse(input, options) {
1551
1724
 
1552
1725
  s0 = peg$currPos;
1553
1726
  peg$savedPos = peg$currPos;
1554
- s1 = peg$f43();
1727
+ s1 = peg$f46();
1555
1728
  if (s1) {
1556
1729
  s1 = undefined;
1557
1730
  } else {
@@ -1567,7 +1740,7 @@ function peg$parse(input, options) {
1567
1740
  }
1568
1741
  if (s2 !== peg$FAILED) {
1569
1742
  peg$savedPos = s0;
1570
- s0 = peg$f44(s2);
1743
+ s0 = peg$f47(s2);
1571
1744
  } else {
1572
1745
  peg$currPos = s0;
1573
1746
  s0 = peg$FAILED;
@@ -1586,7 +1759,7 @@ function peg$parse(input, options) {
1586
1759
  s0 = peg$currPos;
1587
1760
  s1 = '';
1588
1761
  peg$savedPos = s0;
1589
- s1 = peg$f45();
1762
+ s1 = peg$f48();
1590
1763
  s0 = s1;
1591
1764
 
1592
1765
  return s0;
@@ -1598,24 +1771,24 @@ function peg$parse(input, options) {
1598
1771
  s0 = peg$currPos;
1599
1772
  s1 = [];
1600
1773
  if (input.charCodeAt(peg$currPos) === 32) {
1601
- s2 = peg$c6;
1774
+ s2 = peg$c9;
1602
1775
  peg$currPos++;
1603
1776
  } else {
1604
1777
  s2 = peg$FAILED;
1605
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1778
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1606
1779
  }
1607
1780
  while (s2 !== peg$FAILED) {
1608
1781
  s1.push(s2);
1609
1782
  if (input.charCodeAt(peg$currPos) === 32) {
1610
- s2 = peg$c6;
1783
+ s2 = peg$c9;
1611
1784
  peg$currPos++;
1612
1785
  } else {
1613
1786
  s2 = peg$FAILED;
1614
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1787
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1615
1788
  }
1616
1789
  }
1617
1790
  peg$savedPos = s0;
1618
- s1 = peg$f46(s1);
1791
+ s1 = peg$f49(s1);
1619
1792
  s0 = s1;
1620
1793
 
1621
1794
  return s0;
@@ -1627,24 +1800,24 @@ function peg$parse(input, options) {
1627
1800
  s0 = peg$currPos;
1628
1801
  s1 = [];
1629
1802
  if (input.charCodeAt(peg$currPos) === 32) {
1630
- s2 = peg$c6;
1803
+ s2 = peg$c9;
1631
1804
  peg$currPos++;
1632
1805
  } else {
1633
1806
  s2 = peg$FAILED;
1634
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1807
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1635
1808
  }
1636
1809
  while (s2 !== peg$FAILED) {
1637
1810
  s1.push(s2);
1638
1811
  if (input.charCodeAt(peg$currPos) === 32) {
1639
- s2 = peg$c6;
1812
+ s2 = peg$c9;
1640
1813
  peg$currPos++;
1641
1814
  } else {
1642
1815
  s2 = peg$FAILED;
1643
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1816
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1644
1817
  }
1645
1818
  }
1646
1819
  peg$savedPos = peg$currPos;
1647
- s2 = peg$f47(s1);
1820
+ s2 = peg$f50(s1);
1648
1821
  if (s2) {
1649
1822
  s2 = undefined;
1650
1823
  } else {
@@ -1652,7 +1825,7 @@ function peg$parse(input, options) {
1652
1825
  }
1653
1826
  if (s2 !== peg$FAILED) {
1654
1827
  peg$savedPos = s0;
1655
- s0 = peg$f48(s1);
1828
+ s0 = peg$f51(s1);
1656
1829
  } else {
1657
1830
  peg$currPos = s0;
1658
1831
  s0 = peg$FAILED;
@@ -1667,24 +1840,24 @@ function peg$parse(input, options) {
1667
1840
  s0 = peg$currPos;
1668
1841
  s1 = [];
1669
1842
  if (input.charCodeAt(peg$currPos) === 32) {
1670
- s2 = peg$c6;
1843
+ s2 = peg$c9;
1671
1844
  peg$currPos++;
1672
1845
  } else {
1673
1846
  s2 = peg$FAILED;
1674
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1847
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1675
1848
  }
1676
1849
  while (s2 !== peg$FAILED) {
1677
1850
  s1.push(s2);
1678
1851
  if (input.charCodeAt(peg$currPos) === 32) {
1679
- s2 = peg$c6;
1852
+ s2 = peg$c9;
1680
1853
  peg$currPos++;
1681
1854
  } else {
1682
1855
  s2 = peg$FAILED;
1683
- if (peg$silentFails === 0) { peg$fail(peg$e9); }
1856
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
1684
1857
  }
1685
1858
  }
1686
1859
  peg$savedPos = peg$currPos;
1687
- s2 = peg$f49(s1);
1860
+ s2 = peg$f52(s1);
1688
1861
  if (s2) {
1689
1862
  s2 = undefined;
1690
1863
  } else {
@@ -1884,7 +2057,7 @@ function peg$parse(input, options) {
1884
2057
 
1885
2058
  s0 = peg$currPos;
1886
2059
  peg$savedPos = peg$currPos;
1887
- s1 = peg$f50();
2060
+ s1 = peg$f53();
1888
2061
  if (s1) {
1889
2062
  s1 = undefined;
1890
2063
  } else {
@@ -1987,11 +2160,11 @@ function peg$parse(input, options) {
1987
2160
  let s0;
1988
2161
 
1989
2162
  s0 = input.charAt(peg$currPos);
1990
- if (peg$r2.test(s0)) {
2163
+ if (peg$r4.test(s0)) {
1991
2164
  peg$currPos++;
1992
2165
  } else {
1993
2166
  s0 = peg$FAILED;
1994
- if (peg$silentFails === 0) { peg$fail(peg$e10); }
2167
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
1995
2168
  }
1996
2169
 
1997
2170
  return s0;
@@ -2001,11 +2174,11 @@ function peg$parse(input, options) {
2001
2174
  let s0;
2002
2175
 
2003
2176
  s0 = input.charAt(peg$currPos);
2004
- if (peg$r3.test(s0)) {
2177
+ if (peg$r5.test(s0)) {
2005
2178
  peg$currPos++;
2006
2179
  } else {
2007
2180
  s0 = peg$FAILED;
2008
- if (peg$silentFails === 0) { peg$fail(peg$e11); }
2181
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
2009
2182
  }
2010
2183
 
2011
2184
  return s0;
@@ -23,7 +23,9 @@ test('binary text quotes every Unicode grammar whitespace character', () => {
23
23
  '\u001f',
24
24
  '\ufeff',
25
25
  ]) {
26
- expect(formatBinaryReference(text)).toBe("'" + text + "'");
26
+ expect(
27
+ new Parser().parse(`(root: ${formatBinaryReference(text)})`)
28
+ ).toEqual([new Link('root', [new Link(text)])]);
27
29
  }
28
30
  });
29
31
 
@@ -86,6 +86,6 @@ test('TestEmptyReferenceSurvivesARoundTrip', () => {
86
86
  }
87
87
  });
88
88
 
89
- test('TestEmptyReferenceIsWrittenAsADelimiterPair', () => {
90
- expect(formatLinks(parser.parse('(a "" b)'))).toBe('(a "" b)');
89
+ test('TestEmptyReferenceIsWrittenAsAVersionedLiteral', () => {
90
+ expect(formatLinks(parser.parse('(a "" b)'))).toBe('(a ~1{} b)');
91
91
  });