tarsec 0.1.4 → 0.1.5
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.
- package/dist/combinators.js +6 -5
- package/package.json +1 -1
package/dist/combinators.js
CHANGED
|
@@ -876,9 +876,10 @@ export function parseError(_message, ...parsers) {
|
|
|
876
876
|
const prefix = "Near: ";
|
|
877
877
|
if (input.length > 0) {
|
|
878
878
|
const index = inputStr.length - input.length;
|
|
879
|
-
const start = Math.max(0,
|
|
880
|
-
const end = Math.min(inputStr.length,
|
|
881
|
-
|
|
879
|
+
const start = Math.max(0, index - 20);
|
|
880
|
+
const end = Math.min(inputStr.length, index + 20);
|
|
881
|
+
const previewStr = inputStr.substring(start, end).split("\n")[0];
|
|
882
|
+
messages.push(`${prefix}${previewStr}`);
|
|
882
883
|
messages.push(`${" ".repeat(index + prefix.length)}^`);
|
|
883
884
|
messages.push(_message);
|
|
884
885
|
const message = messages.join("\n");
|
|
@@ -889,9 +890,9 @@ export function parseError(_message, ...parsers) {
|
|
|
889
890
|
acc += lines[i].length;
|
|
890
891
|
i++;
|
|
891
892
|
}
|
|
892
|
-
const column = acc - index;
|
|
893
|
+
const column = lines[i - 1].length - (acc - index);
|
|
893
894
|
throw new TarsecError({
|
|
894
|
-
line: i,
|
|
895
|
+
line: i - 1,
|
|
895
896
|
column,
|
|
896
897
|
length: 1,
|
|
897
898
|
prettyMessage: message,
|