-
Notifications
You must be signed in to change notification settings - Fork 419
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
Nonsense error messages, such as 'Line 1, column 3: Expected "a" but "a" found'. #119
Comments
I think the correct error should be: |
@chrisdew I reduced the testcase further: Grammar
Input
With both 0.7.0 and the current development version, the error message is:
It should be:
When I change the grammar to:
the message changes to:
It should be:
In short — this is a valid bug and I'll fix it. Thanks for reporting it. |
Thanks for writing this library, I look forward to a fix. |
Hi, any news on this bug? |
@chrisdew Sorry this took so long. I wanted to redesign the error reporting first. Once done, the fix (or rather, its core) was trivial. |
@dmajda Thanks for the fix - I'll have a look soon. |
In case the generated parser parsed successfully part of input and left some input unparsed (trailing input), the error message produced was sometimes wrong. The code worked correctly only if there were no match failures in the successfully parsed part (highly unlikely). This commit fixes things by explicitly triggering a match failure with the following expectation at the end of the successfully parsed part of the input: peg$fail({ type: "end", description: "end of input" }); This change also made it possible to simplify the |buildMessage| function, which can now ignore the case of no expectations. Fixes pegjs#119.
I keep coming across nonsense error messages with PEG.js, of the form:
Line 1, column 3: Expected "a" but "a" found.
when parsing
bda
.Typically I see them when parsing text which begins with a parseable expression, but adds unneeded text onto the end.
A simple example is:
Could there be a more sane error message, such as 'too much text' instead?
Thanks,
Chris.
The text was updated successfully, but these errors were encountered: