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=b2b66bd74225359c9088808e3a008d5a9f9bba23;hp=5da4bab5343d6f3987041a5cb7821be41a1cd682;hb=018ca0636a427b3f7c231b8b6402146f8c104b5b;hpb=8bf0afa10def1f300d69ca06f4929a8becca8074 diff --git a/lib/rfc8288-web-linking.js b/lib/rfc8288-web-linking.js index 5da4bab..b2b66bd 100644 --- a/lib/rfc8288-web-linking.js +++ b/lib/rfc8288-web-linking.js @@ -1,4 +1,4 @@ -// Generated by Peggy 2.0.1. +// Generated by Peggy 3.0.2. // // https://peggyjs.org/ @@ -69,16 +69,19 @@ peg$SyntaxError.prototype.format = function(sources) { } } var s = this.location.start; - var loc = this.location.source + ":" + s.line + ":" + s.column; + var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) + ? this.location.source.offset(s) + : s; + var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; if (src) { var e = this.location.end; - var filler = peg$padEnd("", s.line.toString().length, ' '); + var filler = peg$padEnd("", offset_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" + + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, ' ') + peg$padEnd("", hatLen, "^"); } else { @@ -420,11 +423,11 @@ function peg$parse(input, options) { } } - function peg$computeLocation(startPos, endPos) { + function peg$computeLocation(startPos, endPos, offset) { var startPosDetails = peg$computePosDetails(startPos); var endPosDetails = peg$computePosDetails(endPos); - return { + var res = { source: peg$source, start: { offset: startPos, @@ -437,6 +440,11 @@ function peg$parse(input, options) { column: endPosDetails.column } }; + if (offset && peg$source && (typeof peg$source.offset === "function")) { + res.start = peg$source.offset(res.start); + res.end = peg$source.offset(res.end); + } + return res; } function peg$fail(expected) {