erikrose / parsimonious

The fastest pure-Python PEG parser I can muster
MIT License
1.79k stars 126 forks source link

How to get better parse errors? #239

Open Philogy opened 9 months ago

Philogy commented 9 months ago

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! 🙏