Improving ANTLR DSL parse-error messages
Posted
by Dan Fabulich
on Stack Overflow
See other posts from Stack Overflow
or by Dan Fabulich
Published on 2010-02-14T23:45:43Z
Indexed on
2010/03/17
15:51 UTC
Read the original article
Hit count: 797
I'm working on a domain-specific language (DSL) for non-programmers. Non-programmers make a lot of grammar mistakes: they misspell keywords, they don't close parentheses, they don't terminate blocks, etc.
I'm using ANTLR to generate my parser; it provides a nifty mechanism for handling RecognitionExceptions to improve error handling. But I'm finding it pretty hard to develop good error-handling code for my DSL.
At this point, I'm considering ways to simplify the language to make it easier for me to provide users with high-quality error messages, but I'm not really sure how to go about this. I think I want to reduce the ambiguity of errors somehow, but I'm not sure how to implement that idea in a grammar.
In what ways can I simplify my language to improve parse-error messages for my users?
EDIT: Updated to clarify that I'm interested in ways to simplify my language, not just ANTLR error-handling tips in general. (Though, thanks for those!)
© Stack Overflow or respective owner