It would be very handy if parsers generated by pe were able to produce proper error messages when they fail to parse a given input. This includes pointing out the longest possible sequence of the input that the parser was able to match and then telling the user what the parser would have expected in order to continue matching from there.
E.g. when using a grammar such as
matching an input of Hello should say something like At line 1, col 5: Expected "world" or if there were multiple alternatives:
match < "Hello" ("world" / "universe")
At line 1, col 5: Expected one of: "world", "universe"
For character classes one can simply print their definition as the expected value and for rule references print the name of the rule.
See e.g. the error messages that ANTLR produces.
It would be very handy if parsers generated by
pewere able to produce proper error messages when they fail to parse a given input. This includes pointing out the longest possible sequence of the input that the parser was able to match and then telling the user what the parser would have expected in order to continue matching from there.E.g. when using a grammar such as
matching an input of
Helloshould say something likeAt line 1, col 5: Expected "world"or if there were multiple alternatives:At line 1, col 5: Expected one of: "world", "universe"For character classes one can simply print their definition as the expected value and for rule references print the name of the rule.
See e.g. the error messages that ANTLR produces.