Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error reported in the wrong place #65

Open
OptiverTimAll opened this issue Jul 14, 2016 · 1 comment
Open

Parse error reported in the wrong place #65

OptiverTimAll opened this issue Jul 14, 2016 · 1 comment

Comments

@OptiverTimAll
Copy link

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.

@crackwitz
Copy link

it's calculating the line and column wrong. there's clearly no line 2.

this is caused by "off-by-1" errors in one or more places. when that's fixed, the position makes sense again.

some error reporting is also misleading/wrong, e.g. an "expected EOF" error when the parser is at the end of input... the input was simply incomplete, yet it doesn't say more than that.

it seems to me like this project is abandoned and nobody has had any interest in it in years.

my attempt at shallowly fixing this: crackwitz@515346c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants