X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Frfc8288-web-linking.js;h=6bdc1884cf5f5f1ab1a93b049b530b5fce1d23d9;hb=HEAD;hp=0466da9acb3c25b47b054afda97e8e8617e17f22;hpb=85fac34dafe84dec74c7c458fd26998d59c23b72;p=squeep-web-linking diff --git a/lib/rfc8288-web-linking.js b/lib/rfc8288-web-linking.js index 0466da9..e3b988f 100644 --- a/lib/rfc8288-web-linking.js +++ b/lib/rfc8288-web-linking.js @@ -1,12 +1,14 @@ -// Generated by Peggy 3.0.2. +// @generated by Peggy 4.0.2. // // https://peggyjs.org/ "use strict"; + /* Generated code is not pretty, ignore a lot of this horrorstyle. */ /* eslint-disable no-control-regex */ +/* eslint-disable no-empty */ /* eslint-disable security/detect-object-injection */ /* eslint-disable brace-style */ /* eslint-disable comma-dangle */ @@ -315,16 +317,16 @@ function peg$parse(input, options) { value: makeString(value), }; }; - var peg$currPos = 0; - var peg$savedPos = 0; + var peg$currPos = options.peg$currPos | 0; + var peg$savedPos = peg$currPos; var peg$posDetailsCache = [{ line: 1, column: 1 }]; - var peg$maxFailPos = 0; - var peg$maxFailExpected = []; - var peg$silentFails = 0; + var peg$maxFailPos = peg$currPos; + var peg$maxFailExpected = options.peg$maxFailExpected || []; + var peg$silentFails = options.peg$silentFails | 0; var peg$result; - if ("startRule" in options) { + if (options.startRule) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } @@ -399,9 +401,11 @@ function peg$parse(input, options) { if (details) { return details; } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; + if (pos >= peg$posDetailsCache.length) { + p = peg$posDetailsCache.length - 1; + } else { + p = pos; + while (!peg$posDetailsCache[--p]) {} } details = peg$posDetailsCache[p]; @@ -608,8 +612,8 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; s1 = []; - if (peg$r0.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -618,8 +622,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r0.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -754,8 +758,8 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; s1 = []; - if (peg$r1.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r1.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -764,8 +768,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r1.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r1.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -806,8 +810,8 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; - if (peg$r2.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r2.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; @@ -815,8 +819,8 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { s2 = []; - if (peg$r3.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); + s3 = input.charAt(peg$currPos); + if (peg$r3.test(s3)) { peg$currPos++; } else { s3 = peg$FAILED; @@ -825,8 +829,8 @@ function peg$parse(input, options) { if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$r3.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); + s3 = input.charAt(peg$currPos); + if (peg$r3.test(s3)) { peg$currPos++; } else { s3 = peg$FAILED; @@ -837,8 +841,8 @@ function peg$parse(input, options) { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { - if (peg$r2.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); + s3 = input.charAt(peg$currPos); + if (peg$r2.test(s3)) { peg$currPos++; } else { s3 = peg$FAILED; @@ -862,8 +866,8 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = []; - if (peg$r4.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r4.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -872,8 +876,8 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r4.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r4.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -903,8 +907,8 @@ function peg$parse(input, options) { peg$silentFails++; s0 = []; - if (peg$r5.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r5.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; @@ -912,8 +916,8 @@ function peg$parse(input, options) { } while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$r5.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); + s1 = input.charAt(peg$currPos); + if (peg$r5.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; @@ -945,8 +949,8 @@ function peg$parse(input, options) { peg$silentFails++; s0 = peg$currPos; s1 = []; - if (peg$r6.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r6.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -954,16 +958,16 @@ function peg$parse(input, options) { } while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$r6.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r6.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e23); } } } - if (peg$r7.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r7.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; @@ -971,8 +975,8 @@ function peg$parse(input, options) { } if (s2 !== peg$FAILED) { s3 = []; - if (peg$r6.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); + s4 = input.charAt(peg$currPos); + if (peg$r6.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; @@ -980,16 +984,16 @@ function peg$parse(input, options) { } while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$r6.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); + s4 = input.charAt(peg$currPos); + if (peg$r6.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e23); } } } - if (peg$r7.test(input.charAt(peg$currPos))) { - s4 = input.charAt(peg$currPos); + s4 = input.charAt(peg$currPos); + if (peg$r7.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; @@ -1063,6 +1067,15 @@ let seenAttributes = []; peg$result = peg$startRuleFunction(); + if (options.peg$library) { + return /** @type {any} */ ({ + peg$result, + peg$currPos, + peg$FAILED, + peg$maxFailExpected, + peg$maxFailPos + }); + } if (peg$result !== peg$FAILED && peg$currPos === input.length) { return peg$result; } else { @@ -1081,6 +1094,7 @@ let seenAttributes = []; } module.exports = { + StartRules: ["links", "extendedValue"], SyntaxError: peg$SyntaxError, parse: peg$parse };