single-file-core 1.2.13 → 1.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,856 @@
1
+ /*
2
+ * Copyright 2010-2022 Gildas Lormeau
3
+ * contact : gildas.lormeau <at> gmail.com
4
+ *
5
+ * This file is part of SingleFile.
6
+ *
7
+ * The code in this file is free software: you can redistribute it and/or
8
+ * modify it under the terms of the GNU Affero General Public License
9
+ * (GNU AGPL) as published by the Free Software Foundation, either version 3
10
+ * of the License, or (at your option) any later version.
11
+ *
12
+ * The code in this file is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
15
+ * General Public License for more details.
16
+ *
17
+ * As additional permission under GNU AGPL version 3 section 7, you may
18
+ * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
19
+ * AGPL normally required by section 4, provided you include this license
20
+ * notice and a URL through which recipients can access the Corresponding
21
+ * Source.
22
+ */
23
+
24
+ /* eslint-disable no-control-regex */
25
+
26
+ /*
27
+ * Generated by PEG.js 0.10.0.
28
+ *
29
+ * http://pegjs.org/
30
+ */
31
+
32
+ /* Modified manually by Gildas Lormeau in order to support async/await callbacks */
33
+
34
+ export {
35
+ peg$SyntaxError as SyntaxError,
36
+ peg$parse as parse
37
+ };
38
+
39
+ function peg$subclass(child, parent) {
40
+ function ctor() { this.constructor = child; }
41
+ ctor.prototype = parent.prototype;
42
+ child.prototype = new ctor();
43
+ }
44
+
45
+ function peg$SyntaxError(message, expected, found, location) {
46
+ this.message = message;
47
+ this.expected = expected;
48
+ this.found = found;
49
+ this.location = location;
50
+ this.name = "SyntaxError";
51
+
52
+ if (typeof Error.captureStackTrace === "function") {
53
+ Error.captureStackTrace(this, peg$SyntaxError);
54
+ }
55
+ }
56
+
57
+ peg$subclass(peg$SyntaxError, Error);
58
+
59
+ peg$SyntaxError.buildMessage = function (expected, found) {
60
+ var DESCRIBE_EXPECTATION_FNS = {
61
+ literal: function (expectation) {
62
+ return "\"" + literalEscape(expectation.text) + "\"";
63
+ },
64
+
65
+ "class": function (expectation) {
66
+ var escapedParts = "",
67
+ i;
68
+
69
+ for (i = 0; i < expectation.parts.length; i++) {
70
+ escapedParts += expectation.parts[i] instanceof Array
71
+ ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
72
+ : classEscape(expectation.parts[i]);
73
+ }
74
+
75
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
76
+ },
77
+
78
+ any: function () {
79
+ return "any character";
80
+ },
81
+
82
+ end: function () {
83
+ return "end of input";
84
+ },
85
+
86
+ other: function (expectation) {
87
+ return expectation.description;
88
+ }
89
+ };
90
+
91
+ function hex(ch) {
92
+ return ch.charCodeAt(0).toString(16).toUpperCase();
93
+ }
94
+
95
+ function literalEscape(s) {
96
+ return s
97
+ .replace(/\\/g, "\\\\")
98
+ .replace(/"/g, "\\\"")
99
+ .replace(/\0/g, "\\0")
100
+ .replace(/\t/g, "\\t")
101
+ .replace(/\n/g, "\\n")
102
+ .replace(/\r/g, "\\r")
103
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
104
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
105
+ }
106
+
107
+ function classEscape(s) {
108
+ return s
109
+ .replace(/\\/g, "\\\\")
110
+ .replace(/\]/g, "\\]")
111
+ .replace(/\^/g, "\\^")
112
+ .replace(/-/g, "\\-")
113
+ .replace(/\0/g, "\\0")
114
+ .replace(/\t/g, "\\t")
115
+ .replace(/\n/g, "\\n")
116
+ .replace(/\r/g, "\\r")
117
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
118
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
119
+ }
120
+
121
+ function describeExpectation(expectation) {
122
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
123
+ }
124
+
125
+ function describeExpected(expected) {
126
+ var descriptions = new Array(expected.length),
127
+ i, j;
128
+
129
+ for (i = 0; i < expected.length; i++) {
130
+ descriptions[i] = describeExpectation(expected[i]);
131
+ }
132
+
133
+ descriptions.sort();
134
+
135
+ if (descriptions.length > 0) {
136
+ for (i = 1, j = 1; i < descriptions.length; i++) {
137
+ if (descriptions[i - 1] !== descriptions[i]) {
138
+ descriptions[j] = descriptions[i];
139
+ j++;
140
+ }
141
+ }
142
+ descriptions.length = j;
143
+ }
144
+
145
+ switch (descriptions.length) {
146
+ case 1:
147
+ return descriptions[0];
148
+
149
+ case 2:
150
+ return descriptions[0] + " or " + descriptions[1];
151
+
152
+ default:
153
+ return descriptions.slice(0, -1).join(", ")
154
+ + ", or "
155
+ + descriptions[descriptions.length - 1];
156
+ }
157
+ }
158
+
159
+ function describeFound(found) {
160
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
161
+ }
162
+
163
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
164
+ };
165
+
166
+ async function peg$parse(input, options) {
167
+ options = options !== void 0 ? options : {};
168
+
169
+ var peg$FAILED = {},
170
+
171
+ peg$startRuleFunctions = { start: peg$parsestart },
172
+ peg$startRuleFunction = peg$parsestart,
173
+
174
+ peg$c0 = "|",
175
+ peg$c1 = peg$literalExpectation("|", false),
176
+ peg$c2 = function (value) { return value; },
177
+ peg$c3 = "%",
178
+ peg$c4 = peg$literalExpectation("%", false),
179
+ peg$c5 = "<",
180
+ peg$c6 = peg$literalExpectation("<", false),
181
+ peg$c7 = ">",
182
+ peg$c8 = peg$literalExpectation(">", false),
183
+ peg$c9 = function (name, args, length) { return options.callFunction(name, args, length); },
184
+ peg$c10 = "{",
185
+ peg$c11 = peg$literalExpectation("{", false),
186
+ peg$c12 = "}",
187
+ peg$c13 = peg$literalExpectation("}", false),
188
+ peg$c14 = function (name, length) { return options.getVariableValue(name, length); },
189
+ peg$c15 = "[",
190
+ peg$c16 = peg$literalExpectation("[", false),
191
+ peg$c17 = "]",
192
+ peg$c18 = peg$literalExpectation("]", false),
193
+ peg$c19 = function (length, unit) { return { length, unit }; },
194
+ peg$c20 = "ch",
195
+ peg$c21 = peg$literalExpectation("ch", false),
196
+ peg$c22 = /^[a-z0-9-]/,
197
+ peg$c23 = peg$classExpectation([["a", "z"], ["0", "9"], "-"], false, false),
198
+ peg$c24 = function () { return text(); },
199
+ peg$c25 = /^[0-9]/,
200
+ peg$c26 = peg$classExpectation([["0", "9"]], false, false),
201
+ peg$c27 = function () { return Number(text()); },
202
+ peg$c28 = "\\\\{",
203
+ peg$c29 = peg$literalExpectation("\\\\{", false),
204
+ peg$c30 = "\\\\>",
205
+ peg$c31 = peg$literalExpectation("\\\\>", false),
206
+ peg$c32 = "\\\\%",
207
+ peg$c33 = peg$literalExpectation("\\\\%", false),
208
+ peg$c34 = "\\\\|",
209
+ peg$c35 = peg$literalExpectation("\\\\|", false),
210
+ peg$c36 = peg$anyExpectation(),
211
+
212
+ peg$currPos = 0,
213
+ peg$savedPos = 0,
214
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
215
+ peg$maxFailPos = 0,
216
+ peg$maxFailExpected = [],
217
+ peg$silentFails = 0,
218
+
219
+ peg$result;
220
+
221
+ if ("startRule" in options) {
222
+ if (!(options.startRule in peg$startRuleFunctions)) {
223
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
224
+ }
225
+
226
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
227
+ }
228
+
229
+ function text() {
230
+ return input.substring(peg$savedPos, peg$currPos);
231
+ }
232
+
233
+ function peg$literalExpectation(text, ignoreCase) {
234
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
235
+ }
236
+
237
+ function peg$classExpectation(parts, inverted, ignoreCase) {
238
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
239
+ }
240
+
241
+ function peg$anyExpectation() {
242
+ return { type: "any" };
243
+ }
244
+
245
+ function peg$endExpectation() {
246
+ return { type: "end" };
247
+ }
248
+
249
+ function peg$computePosDetails(pos) {
250
+ var details = peg$posDetailsCache[pos], p;
251
+
252
+ if (details) {
253
+ return details;
254
+ } else {
255
+ p = pos - 1;
256
+ while (!peg$posDetailsCache[p]) {
257
+ p--;
258
+ }
259
+
260
+ details = peg$posDetailsCache[p];
261
+ details = {
262
+ line: details.line,
263
+ column: details.column
264
+ };
265
+
266
+ while (p < pos) {
267
+ if (input.charCodeAt(p) === 10) {
268
+ details.line++;
269
+ details.column = 1;
270
+ } else {
271
+ details.column++;
272
+ }
273
+
274
+ p++;
275
+ }
276
+
277
+ peg$posDetailsCache[pos] = details;
278
+ return details;
279
+ }
280
+ }
281
+
282
+ function peg$computeLocation(startPos, endPos) {
283
+ var startPosDetails = peg$computePosDetails(startPos),
284
+ endPosDetails = peg$computePosDetails(endPos);
285
+
286
+ return {
287
+ start: {
288
+ offset: startPos,
289
+ line: startPosDetails.line,
290
+ column: startPosDetails.column
291
+ },
292
+ end: {
293
+ offset: endPos,
294
+ line: endPosDetails.line,
295
+ column: endPosDetails.column
296
+ }
297
+ };
298
+ }
299
+
300
+ function peg$fail(expected) {
301
+ if (peg$currPos < peg$maxFailPos) { return; }
302
+
303
+ if (peg$currPos > peg$maxFailPos) {
304
+ peg$maxFailPos = peg$currPos;
305
+ peg$maxFailExpected = [];
306
+ }
307
+
308
+ peg$maxFailExpected.push(expected);
309
+ }
310
+
311
+ function peg$buildStructuredError(expected, found, location) {
312
+ return new peg$SyntaxError(
313
+ peg$SyntaxError.buildMessage(expected, found),
314
+ expected,
315
+ found,
316
+ location
317
+ );
318
+ }
319
+
320
+ async function peg$parsestart() {
321
+ var s0;
322
+
323
+ s0 = await peg$parseexpression();
324
+
325
+ return s0;
326
+ }
327
+
328
+ async function peg$parseexpression() {
329
+ var s0, s1;
330
+
331
+ s0 = [];
332
+ s1 = await peg$parsestatement();
333
+ while (s1 !== peg$FAILED) {
334
+ s0.push(s1);
335
+ s1 = await peg$parsestatement();
336
+ }
337
+
338
+ return s0;
339
+ }
340
+
341
+ async function peg$parsestatement() {
342
+ var s0;
343
+
344
+ s0 = await peg$parsefunctionCall();
345
+ if (s0 === peg$FAILED) {
346
+ s0 = await peg$parsevariable();
347
+ if (s0 === peg$FAILED) {
348
+ s0 = peg$parsetext();
349
+ }
350
+ }
351
+
352
+ return s0;
353
+ }
354
+
355
+ async function peg$parsearg() {
356
+ var s0, s1, s2;
357
+
358
+ s0 = peg$currPos;
359
+ if (input.charCodeAt(peg$currPos) === 124) {
360
+ s1 = peg$c0;
361
+ peg$currPos++;
362
+ } else {
363
+ s1 = peg$FAILED;
364
+ if (peg$silentFails === 0) { peg$fail(peg$c1); }
365
+ }
366
+ if (s1 === peg$FAILED) {
367
+ s1 = null;
368
+ }
369
+ if (s1 !== peg$FAILED) {
370
+ s2 = await peg$parsestatement();
371
+ if (s2 !== peg$FAILED) {
372
+ peg$savedPos = s0;
373
+ s1 = peg$c2(s2);
374
+ s0 = s1;
375
+ } else {
376
+ peg$currPos = s0;
377
+ s0 = peg$FAILED;
378
+ }
379
+ } else {
380
+ peg$currPos = s0;
381
+ s0 = peg$FAILED;
382
+ }
383
+
384
+ return s0;
385
+ }
386
+
387
+ async function peg$parseargs() {
388
+ var s0, s1, s2, s3;
389
+
390
+ s0 = peg$currPos;
391
+ s1 = await peg$parsearg();
392
+ if (s1 !== peg$FAILED) {
393
+ s2 = [];
394
+ s3 = await peg$parsearg();
395
+ while (s3 !== peg$FAILED) {
396
+ s2.push(s3);
397
+ s3 = await peg$parsearg();
398
+ }
399
+ if (s2 !== peg$FAILED) {
400
+ s1 = [s1, s2];
401
+ s0 = s1;
402
+ } else {
403
+ peg$currPos = s0;
404
+ s0 = peg$FAILED;
405
+ }
406
+ } else {
407
+ peg$currPos = s0;
408
+ s0 = peg$FAILED;
409
+ }
410
+
411
+ return s0;
412
+ }
413
+
414
+ async function peg$parsefunctionCall() {
415
+ var s0, s1, s2, s3, s4, s5, s6;
416
+
417
+ s0 = peg$currPos;
418
+ if (input.charCodeAt(peg$currPos) === 37) {
419
+ s1 = peg$c3;
420
+ peg$currPos++;
421
+ } else {
422
+ s1 = peg$FAILED;
423
+ if (peg$silentFails === 0) { peg$fail(peg$c4); }
424
+ }
425
+ if (s1 !== peg$FAILED) {
426
+ s2 = peg$parseidentifier();
427
+ if (s2 !== peg$FAILED) {
428
+ if (input.charCodeAt(peg$currPos) === 60) {
429
+ s3 = peg$c5;
430
+ peg$currPos++;
431
+ } else {
432
+ s3 = peg$FAILED;
433
+ if (peg$silentFails === 0) { peg$fail(peg$c6); }
434
+ }
435
+ if (s3 !== peg$FAILED) {
436
+ s4 = await peg$parseargs();
437
+ if (s4 !== peg$FAILED) {
438
+ if (input.charCodeAt(peg$currPos) === 62) {
439
+ s5 = peg$c7;
440
+ peg$currPos++;
441
+ } else {
442
+ s5 = peg$FAILED;
443
+ if (peg$silentFails === 0) { peg$fail(peg$c8); }
444
+ }
445
+ if (s5 !== peg$FAILED) {
446
+ s6 = peg$parseresultLength();
447
+ if (s6 === peg$FAILED) {
448
+ s6 = null;
449
+ }
450
+ if (s6 !== peg$FAILED) {
451
+ peg$savedPos = s0;
452
+ s1 = await peg$c9(s2, s4, s6);
453
+ s0 = s1;
454
+ } else {
455
+ peg$currPos = s0;
456
+ s0 = peg$FAILED;
457
+ }
458
+ } else {
459
+ peg$currPos = s0;
460
+ s0 = peg$FAILED;
461
+ }
462
+ } else {
463
+ peg$currPos = s0;
464
+ s0 = peg$FAILED;
465
+ }
466
+ } else {
467
+ peg$currPos = s0;
468
+ s0 = peg$FAILED;
469
+ }
470
+ } else {
471
+ peg$currPos = s0;
472
+ s0 = peg$FAILED;
473
+ }
474
+ } else {
475
+ peg$currPos = s0;
476
+ s0 = peg$FAILED;
477
+ }
478
+
479
+ return s0;
480
+ }
481
+
482
+ async function peg$parsevariable() {
483
+ var s0, s1, s2, s3, s4;
484
+
485
+ s0 = peg$currPos;
486
+ if (input.charCodeAt(peg$currPos) === 123) {
487
+ s1 = peg$c10;
488
+ peg$currPos++;
489
+ } else {
490
+ s1 = peg$FAILED;
491
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
492
+ }
493
+ if (s1 !== peg$FAILED) {
494
+ s2 = peg$parseidentifier();
495
+ if (s2 !== peg$FAILED) {
496
+ if (input.charCodeAt(peg$currPos) === 125) {
497
+ s3 = peg$c12;
498
+ peg$currPos++;
499
+ } else {
500
+ s3 = peg$FAILED;
501
+ if (peg$silentFails === 0) { peg$fail(peg$c13); }
502
+ }
503
+ if (s3 !== peg$FAILED) {
504
+ s4 = peg$parseresultLength();
505
+ if (s4 === peg$FAILED) {
506
+ s4 = null;
507
+ }
508
+ if (s4 !== peg$FAILED) {
509
+ peg$savedPos = s0;
510
+ s1 = await peg$c14(s2, s4);
511
+ s0 = s1;
512
+ } else {
513
+ peg$currPos = s0;
514
+ s0 = peg$FAILED;
515
+ }
516
+ } else {
517
+ peg$currPos = s0;
518
+ s0 = peg$FAILED;
519
+ }
520
+ } else {
521
+ peg$currPos = s0;
522
+ s0 = peg$FAILED;
523
+ }
524
+ } else {
525
+ peg$currPos = s0;
526
+ s0 = peg$FAILED;
527
+ }
528
+
529
+ return s0;
530
+ }
531
+
532
+ function peg$parseresultLength() {
533
+ var s0, s1, s2, s3, s4;
534
+
535
+ s0 = peg$currPos;
536
+ if (input.charCodeAt(peg$currPos) === 91) {
537
+ s1 = peg$c15;
538
+ peg$currPos++;
539
+ } else {
540
+ s1 = peg$FAILED;
541
+ if (peg$silentFails === 0) { peg$fail(peg$c16); }
542
+ }
543
+ if (s1 !== peg$FAILED) {
544
+ s2 = peg$parsenumber();
545
+ if (s2 !== peg$FAILED) {
546
+ s3 = peg$parselengthUnit();
547
+ if (s3 !== peg$FAILED) {
548
+ if (input.charCodeAt(peg$currPos) === 93) {
549
+ s4 = peg$c17;
550
+ peg$currPos++;
551
+ } else {
552
+ s4 = peg$FAILED;
553
+ if (peg$silentFails === 0) { peg$fail(peg$c18); }
554
+ }
555
+ if (s4 !== peg$FAILED) {
556
+ peg$savedPos = s0;
557
+ s1 = peg$c19(s2, s3);
558
+ s0 = s1;
559
+ } else {
560
+ peg$currPos = s0;
561
+ s0 = peg$FAILED;
562
+ }
563
+ } else {
564
+ peg$currPos = s0;
565
+ s0 = peg$FAILED;
566
+ }
567
+ } else {
568
+ peg$currPos = s0;
569
+ s0 = peg$FAILED;
570
+ }
571
+ } else {
572
+ peg$currPos = s0;
573
+ s0 = peg$FAILED;
574
+ }
575
+
576
+ return s0;
577
+ }
578
+
579
+ function peg$parselengthUnit() {
580
+ var s0;
581
+
582
+ if (input.substr(peg$currPos, 2) === peg$c20) {
583
+ s0 = peg$c20;
584
+ peg$currPos += 2;
585
+ } else {
586
+ s0 = peg$FAILED;
587
+ if (peg$silentFails === 0) { peg$fail(peg$c21); }
588
+ }
589
+ if (s0 === peg$FAILED) {
590
+ s0 = null;
591
+ }
592
+
593
+ return s0;
594
+ }
595
+
596
+ function peg$parseidentifier() {
597
+ var s0, s1, s2;
598
+
599
+ s0 = peg$currPos;
600
+ s1 = [];
601
+ if (peg$c22.test(input.charAt(peg$currPos))) {
602
+ s2 = input.charAt(peg$currPos);
603
+ peg$currPos++;
604
+ } else {
605
+ s2 = peg$FAILED;
606
+ if (peg$silentFails === 0) { peg$fail(peg$c23); }
607
+ }
608
+ if (s2 !== peg$FAILED) {
609
+ while (s2 !== peg$FAILED) {
610
+ s1.push(s2);
611
+ if (peg$c22.test(input.charAt(peg$currPos))) {
612
+ s2 = input.charAt(peg$currPos);
613
+ peg$currPos++;
614
+ } else {
615
+ s2 = peg$FAILED;
616
+ if (peg$silentFails === 0) { peg$fail(peg$c23); }
617
+ }
618
+ }
619
+ } else {
620
+ s1 = peg$FAILED;
621
+ }
622
+ if (s1 !== peg$FAILED) {
623
+ peg$savedPos = s0;
624
+ s1 = peg$c24();
625
+ }
626
+ s0 = s1;
627
+
628
+ return s0;
629
+ }
630
+
631
+ function peg$parsenumber() {
632
+ var s0, s1, s2;
633
+
634
+ s0 = peg$currPos;
635
+ s1 = [];
636
+ if (peg$c25.test(input.charAt(peg$currPos))) {
637
+ s2 = input.charAt(peg$currPos);
638
+ peg$currPos++;
639
+ } else {
640
+ s2 = peg$FAILED;
641
+ if (peg$silentFails === 0) { peg$fail(peg$c26); }
642
+ }
643
+ if (s2 !== peg$FAILED) {
644
+ while (s2 !== peg$FAILED) {
645
+ s1.push(s2);
646
+ if (peg$c25.test(input.charAt(peg$currPos))) {
647
+ s2 = input.charAt(peg$currPos);
648
+ peg$currPos++;
649
+ } else {
650
+ s2 = peg$FAILED;
651
+ if (peg$silentFails === 0) { peg$fail(peg$c26); }
652
+ }
653
+ }
654
+ } else {
655
+ s1 = peg$FAILED;
656
+ }
657
+ if (s1 !== peg$FAILED) {
658
+ peg$savedPos = s0;
659
+ s1 = peg$c27();
660
+ }
661
+ s0 = s1;
662
+
663
+ return s0;
664
+ }
665
+
666
+ function peg$parsetext() {
667
+ var s0, s1, s2;
668
+
669
+ s0 = peg$currPos;
670
+ s1 = [];
671
+ s2 = peg$parsechar();
672
+ if (s2 !== peg$FAILED) {
673
+ while (s2 !== peg$FAILED) {
674
+ s1.push(s2);
675
+ s2 = peg$parsechar();
676
+ }
677
+ } else {
678
+ s1 = peg$FAILED;
679
+ }
680
+ if (s1 !== peg$FAILED) {
681
+ peg$savedPos = s0;
682
+ s1 = peg$c24();
683
+ }
684
+ s0 = s1;
685
+
686
+ return s0;
687
+ }
688
+
689
+ function peg$parsechar() {
690
+ var s0, s1, s2, s3, s4, s5;
691
+
692
+ s0 = peg$currPos;
693
+ s1 = peg$currPos;
694
+ peg$silentFails++;
695
+ if (input.charCodeAt(peg$currPos) === 123) {
696
+ s2 = peg$c10;
697
+ peg$currPos++;
698
+ } else {
699
+ s2 = peg$FAILED;
700
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
701
+ }
702
+ peg$silentFails--;
703
+ if (s2 === peg$FAILED) {
704
+ s1 = void 0;
705
+ } else {
706
+ peg$currPos = s1;
707
+ s1 = peg$FAILED;
708
+ }
709
+ if (s1 !== peg$FAILED) {
710
+ s2 = peg$currPos;
711
+ peg$silentFails++;
712
+ if (input.charCodeAt(peg$currPos) === 62) {
713
+ s3 = peg$c7;
714
+ peg$currPos++;
715
+ } else {
716
+ s3 = peg$FAILED;
717
+ if (peg$silentFails === 0) { peg$fail(peg$c8); }
718
+ }
719
+ peg$silentFails--;
720
+ if (s3 === peg$FAILED) {
721
+ s2 = void 0;
722
+ } else {
723
+ peg$currPos = s2;
724
+ s2 = peg$FAILED;
725
+ }
726
+ if (s2 !== peg$FAILED) {
727
+ s3 = peg$currPos;
728
+ peg$silentFails++;
729
+ if (input.charCodeAt(peg$currPos) === 37) {
730
+ s4 = peg$c3;
731
+ peg$currPos++;
732
+ } else {
733
+ s4 = peg$FAILED;
734
+ if (peg$silentFails === 0) { peg$fail(peg$c4); }
735
+ }
736
+ peg$silentFails--;
737
+ if (s4 === peg$FAILED) {
738
+ s3 = void 0;
739
+ } else {
740
+ peg$currPos = s3;
741
+ s3 = peg$FAILED;
742
+ }
743
+ if (s3 !== peg$FAILED) {
744
+ s4 = peg$currPos;
745
+ peg$silentFails++;
746
+ if (input.charCodeAt(peg$currPos) === 124) {
747
+ s5 = peg$c0;
748
+ peg$currPos++;
749
+ } else {
750
+ s5 = peg$FAILED;
751
+ if (peg$silentFails === 0) { peg$fail(peg$c1); }
752
+ }
753
+ peg$silentFails--;
754
+ if (s5 === peg$FAILED) {
755
+ s4 = void 0;
756
+ } else {
757
+ peg$currPos = s4;
758
+ s4 = peg$FAILED;
759
+ }
760
+ if (s4 !== peg$FAILED) {
761
+ s5 = peg$parseescapedChar();
762
+ if (s5 !== peg$FAILED) {
763
+ s1 = [s1, s2, s3, s4, s5];
764
+ s0 = s1;
765
+ } else {
766
+ peg$currPos = s0;
767
+ s0 = peg$FAILED;
768
+ }
769
+ } else {
770
+ peg$currPos = s0;
771
+ s0 = peg$FAILED;
772
+ }
773
+ } else {
774
+ peg$currPos = s0;
775
+ s0 = peg$FAILED;
776
+ }
777
+ } else {
778
+ peg$currPos = s0;
779
+ s0 = peg$FAILED;
780
+ }
781
+ } else {
782
+ peg$currPos = s0;
783
+ s0 = peg$FAILED;
784
+ }
785
+
786
+ return s0;
787
+ }
788
+
789
+ function peg$parseescapedChar() {
790
+ var s0;
791
+
792
+ if (input.substr(peg$currPos, 3) === peg$c28) {
793
+ s0 = peg$c28;
794
+ peg$currPos += 3;
795
+ } else {
796
+ s0 = peg$FAILED;
797
+ if (peg$silentFails === 0) { peg$fail(peg$c29); }
798
+ }
799
+ if (s0 === peg$FAILED) {
800
+ if (input.substr(peg$currPos, 3) === peg$c30) {
801
+ s0 = peg$c30;
802
+ peg$currPos += 3;
803
+ } else {
804
+ s0 = peg$FAILED;
805
+ if (peg$silentFails === 0) { peg$fail(peg$c31); }
806
+ }
807
+ if (s0 === peg$FAILED) {
808
+ if (input.substr(peg$currPos, 3) === peg$c32) {
809
+ s0 = peg$c32;
810
+ peg$currPos += 3;
811
+ } else {
812
+ s0 = peg$FAILED;
813
+ if (peg$silentFails === 0) { peg$fail(peg$c33); }
814
+ }
815
+ if (s0 === peg$FAILED) {
816
+ if (input.substr(peg$currPos, 3) === peg$c34) {
817
+ s0 = peg$c34;
818
+ peg$currPos += 3;
819
+ } else {
820
+ s0 = peg$FAILED;
821
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
822
+ }
823
+ if (s0 === peg$FAILED) {
824
+ if (input.length > peg$currPos) {
825
+ s0 = input.charAt(peg$currPos);
826
+ peg$currPos++;
827
+ } else {
828
+ s0 = peg$FAILED;
829
+ if (peg$silentFails === 0) { peg$fail(peg$c36); }
830
+ }
831
+ }
832
+ }
833
+ }
834
+ }
835
+
836
+ return s0;
837
+ }
838
+
839
+ peg$result = await peg$startRuleFunction();
840
+
841
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
842
+ return peg$result;
843
+ } else {
844
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
845
+ peg$fail(peg$endExpectation());
846
+ }
847
+
848
+ throw peg$buildStructuredError(
849
+ peg$maxFailExpected,
850
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
851
+ peg$maxFailPos < input.length
852
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
853
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
854
+ );
855
+ }
856
+ }