parsimonious icon indicating copy to clipboard operation
parsimonious copied to clipboard

How to get better parse errors?

Open Philogy opened this issue 2 years ago • 1 comments

Is there a way to get more precise errors when parsing fails? Currently, when it fails to parse an input string the error seems to just bubble up to the entry expression telling me it failed e.g.:

parsimonious.exceptions.IncompleteParseError: Rule 'program' matched in its entirety, but it didn't consume all the text. The non-matching por
tion of the text begins with '#define macro CONSTR' (line 15, column 1).

Would be great to be able to enable a mode where the error tells you the furthest point that the parser got to in terms of the grammar and also in the input string. I would like my program to be able to give a more helpful error message than just "parsing failed somewhere, dunno what exactly tho".

Thanks a lot! 🙏

Philogy avatar Oct 03 '23 14:10 Philogy

Thanks, @Philogy, for bringing this up, I have exactly the same issue and would be happy, with the solution, you suggest.

Maybe the parser could just support different debug levels and in "DEBUG" mode show the most furthest point.

markdoerr avatar Nov 11 '24 16:11 markdoerr