grappa
grappa copied to clipboard
Allow custom parse error messages
It should be possible to generate custom error messages from a parser. For example with a function like BaseParser.parseError(String message) which causes a parse error with the given custom error message.
Yes, I agree with that.
The (internal) current API however causes two problems:
- error messages are either collected (
ReportingParseRunner, others) or not at all (BasicParseRunner); - the
Ruleinterface leaves no possibility to insert a custom error message; in fact, there is no "errorMessage" field inAbstractMatcher.
I'll have to collect more knowledge on the API to be able to figure out how to collect user error messages, and also the interface to do it, since it's quite important. I thought about something like this:
Rule myRule()
{
return sequence("foo", bar()).errorMessage("no dice...");
}
That is a definite feature I want in 1.0.0 so I'll be working on it. Not sure yet how I'll do it though...