Open
Description
Consider the following Python code:
import parsley
single_digit = parsley.makeGrammar("integer = digit", {})
many_digits = parsley.makeGrammar("integer = digit+", {})
for grammar in (single_digit, many_digits):
try:
grammar("1x").integer()
except Exception as e:
print e
The single_digit
grammar matches 1
, then expects EOF but finds x
instead.
The many_digits
grammar matches 1
, then expects another digit or EOF, but finds x
instead.
I would expect both grammars to have the same, or at least similar parse errors. Instead, with Parsley 1.3 on Python 2.7, I get:
1x
^
Parse error at line 1, column 1: expected EOF. trail: []
1x
^
Parse error at line 2, column 0: expected EOF. trail: [digit]
...that is, single_digit
reports a sensible error at a sensible location, but many_digits
draws the caret under a character that it should have accepted, while reporting an error on line 2 of an input that contains no newline characters.
Metadata
Metadata
Assignees
Labels
No labels