Browse Source

corrected caret placement in error messages due to tabs

fixes #663
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.10.0
starwarswii 4 years ago
committed by GitHub
parent
commit
10dd3d7299
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      lark/exceptions.py

+ 2
- 2
lark/exceptions.py View File

@@ -49,11 +49,11 @@ class UnexpectedInput(LarkError):
if not isinstance(text, bytes):
before = text[start:pos].rsplit('\n', 1)[-1]
after = text[pos:end].split('\n', 1)[0]
return before + after + '\n' + ' ' * len(before) + '^\n'
return before + after + '\n' + ' ' * len(before.expandtabs()) + '^\n'
else:
before = text[start:pos].rsplit(b'\n', 1)[-1]
after = text[pos:end].split(b'\n', 1)[0]
return (before + after + b'\n' + b' ' * len(before) + b'^\n').decode("ascii", "backslashreplace")
return (before + after + b'\n' + b' ' * len(before.expandtabs()) + b'^\n').decode("ascii", "backslashreplace")

def match_examples(self, parse_fn, examples, token_type_match_fallback=False, use_accepts=False):
"""Allows you to detect what's wrong in the input text by matching


Loading…
Cancel
Save