X-Git-Url: http://git.squeep.com/?p=squeep-web-linking;a=blobdiff_plain;f=lib%2Frfc8288-web-linking.js;fp=lib%2Frfc8288-web-linking.js;h=5da4bab5343d6f3987041a5cb7821be41a1cd682;hp=3c41f32180e81a35a7ff0bed74f787d29336af33;hb=a6ebd40f50b4f1277c92e335638d8cfc96ee9cfa;hpb=e2033244c7d8b22d54c0607884a09de627826f84 diff --git a/lib/rfc8288-web-linking.js b/lib/rfc8288-web-linking.js index 3c41f32..5da4bab 100644 --- a/lib/rfc8288-web-linking.js +++ b/lib/rfc8288-web-linking.js @@ -1,4 +1,4 @@ -// Generated by Peggy 1.2.0. +// Generated by Peggy 2.0.1. // // https://peggyjs.org/ @@ -28,7 +28,6 @@ const onlyFirstAttributes = [ ]; - function peg$subclass(child, parent) { function C() { this.constructor = child; } C.prototype = parent.prototype; @@ -37,6 +36,7 @@ function peg$subclass(child, parent) { function peg$SyntaxError(message, expected, found, location) { var self = Error.call(this, message); + // istanbul ignore next Check is a necessary evil to support older environments if (Object.setPrototypeOf) { Object.setPrototypeOf(self, peg$SyntaxError.prototype); } @@ -72,14 +72,15 @@ peg$SyntaxError.prototype.format = function(sources) { var loc = this.location.source + ":" + s.line + ":" + s.column; if (src) { var e = this.location.end; - var filler = peg$padEnd("", s.line.toString().length); + var filler = peg$padEnd("", s.line.toString().length, ' '); var line = src[s.line - 1]; var last = s.line === e.line ? e.column : line.length + 1; + var hatLen = (last - s.column) || 1; str += "\n --> " + loc + "\n" + filler + " |\n" + s.line + " | " + line + "\n" - + filler + " | " + peg$padEnd("", s.column - 1) - + peg$padEnd("", last - s.column, "^"); + + filler + " | " + peg$padEnd("", s.column - 1, ' ') + + peg$padEnd("", hatLen, "^"); } else { str += "\n at " + loc; } @@ -100,7 +101,7 @@ peg$SyntaxError.buildMessage = function(expected, found) { : classEscape(part); }); - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; }, any: function() { @@ -240,69 +241,73 @@ function peg$parse(input, options) { var peg$e25 = peg$anyExpectation(); var peg$f0 = function(links) { - return links; - }; + return links; + }; var peg$f1 = function(uriReference, attributes) { - seenAttributes = []; - return { - target: uriReference, - attributes, - }; + seenAttributes = []; + return { + target: uriReference, + attributes, }; + }; var peg$f2 = function(uri) { - return uri; - }; + return uri; + }; var peg$f3 = function(uri) { - return makeString(uri); - }; + return makeString(uri); + }; var peg$f4 = function(attrs) { - return attrs.filter((a) => a); - }; + return attrs.filter((a) => a); + }; var peg$f5 = function(name, value) { - if (onlyFirstAttributes.includes(name.name)) { - if (seenAttributes.includes(name.name)) { - // Repeat of singleton attribute, ignore it. - return; - } - seenAttributes.push(name.name); + if (onlyFirstAttributes.includes(name.name)) { + if (seenAttributes.includes(name.name)) { + // Repeat of singleton attribute, ignore it. + return; } - return { - ...name, - ...value, - }; + seenAttributes.push(name.name); + } + return { + ...name, + ...value, }; + }; var peg$f6 = function(name) { - return { - ...name, - value: null, - } - }; + return { + ...name, + value: null, + } + }; var peg$f7 = function(name, extended) { - return { - name: makeString(name.concat(extended)).toLowerCase(), - extended: !!extended, - }; + return { + name: makeString(name.concat(extended)).toLowerCase(), + extended: !!extended, }; + }; var peg$f8 = function(value) { - return { - value: makeString(value), - }; + return { + value: makeString(value), }; - var peg$f9 = function(encoding, language, value) { - return { - encoding: encoding.length ? makeString(encoding) : 'UTF-8', - language: language.length ? makeString(language) : null, - value: decodeURIComponent(makeString(value)), - }; + }; + var peg$f9 = function(value) { + return { + value: makeString(value), }; - var peg$f10 = function(value) { - return { - encoding: null, - language: null, - value: makeString(value), - }; + }; + var peg$f10 = function(encoding, language, value) { + return { + encoding: encoding.length ? makeString(encoding) : 'UTF-8', + language: language.length ? makeString(language) : null, + value: decodeURIComponent(makeString(value)), }; - + }; + var peg$f11 = function(value) { + return { + encoding: null, + language: null, + value: makeString(value), + }; + }; var peg$currPos = 0; var peg$savedPos = 0; var peg$posDetailsCache = [{ line: 1, column: 1 }]; @@ -868,7 +873,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f8(s1); + s1 = peg$f9(s1); } s0 = s1; } @@ -998,7 +1003,7 @@ function peg$parse(input, options) { } } peg$savedPos = s0; - s0 = peg$f9(s1, s3, s5); + s0 = peg$f10(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1028,7 +1033,7 @@ function peg$parse(input, options) { } } peg$savedPos = s0; - s1 = peg$f10(s1); + s1 = peg$f11(s1); s0 = s1; } peg$silentFails--; @@ -1041,9 +1046,8 @@ function peg$parse(input, options) { } - // Per-parsing tracking of attributes which should be ignored after first occurrence. - let seenAttributes = []; - +// Per-parsing tracking of attributes which should be ignored after first occurrence. +let seenAttributes = []; peg$result = peg$startRuleFunction();