Skip to content

Commit

Permalink
Fix column numbers indexing
Browse files Browse the repository at this point in the history
SyntaxError expects 1-indexed column numbers, but tokens are 0-indexed.

Fixes we-like-parsers#47
  • Loading branch information
edemaine committed Oct 4, 2021
1 parent c1bb94a commit 80d2e48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions data/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ class Parser(Parser):
self._tokenizer.get_lines(list(range(start[0], end[0] + 1)))
)

args = (self.filename, start[0], start[1], line)
args = (self.filename, start[0], start[1]+1, line)
if sys.version_info >= (3, 10):
args += (end[0], end[1])
args += (end[0], end[1]+1)
self._exception = SyntaxError(message, args)

def store_syntax_error(self, message: str) -> None:
Expand Down

0 comments on commit 80d2e48

Please sign in to comment.