tarsec 0.1.7 → 0.1.8
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 +4 -3
- package/package.json +1 -1
package/dist/combinators.js
CHANGED
|
@@ -874,7 +874,7 @@ export function parseError(_message, ...parsers) {
|
|
|
874
874
|
const inputStr = getInputStr();
|
|
875
875
|
const messages = [];
|
|
876
876
|
const prefix = "Near: ";
|
|
877
|
-
if (
|
|
877
|
+
if (inputStr.length > 0) {
|
|
878
878
|
const index = inputStr.length - input.length;
|
|
879
879
|
const start = Math.max(0, index - 20);
|
|
880
880
|
const end = Math.min(inputStr.length, index + 20);
|
|
@@ -886,11 +886,12 @@ export function parseError(_message, ...parsers) {
|
|
|
886
886
|
const lines = inputStr.split("\n");
|
|
887
887
|
let acc = 0;
|
|
888
888
|
let i = 0;
|
|
889
|
-
while (index
|
|
889
|
+
while (index >= acc) {
|
|
890
890
|
acc += lines[i].length;
|
|
891
891
|
i++;
|
|
892
892
|
}
|
|
893
|
-
const
|
|
893
|
+
const linesIndex = Math.max(0, i - 1);
|
|
894
|
+
const column = lines[linesIndex].length - (acc - index);
|
|
894
895
|
throw new TarsecError({
|
|
895
896
|
line: i - 1,
|
|
896
897
|
column,
|