[antlr-interest] Access to lexer warning/error messages after parsing

Jim Idle jimi at temporal-wave.com
Tue Jul 1 12:07:15 PDT 2008


On Tue, 2008-07-01 at 13:02 -0400, Andy Tripp wrote:

> Jim,
> 
> As you point out, the default case is that people will want to process their own error messages,
> rather than have ANTLR send them to stderr. So doesn't it make more sense to
> have ANTLR package them into a data structure (which has a toString() method
> which ANTLR calls and sends to stderr? The alternative is that people
> have to either parse the error text or look at the ANTLR-generated code to
> understand how to override the default behavior.
> 
> You mention reusing your error handling mechanism across "virtually all" your
> grammars. I think that for almost ANTLR users, the number of lexer/parsers that they're
> going to write is exactly 1. Better to make it as easy as possible to write that
> first grammar and not assume that they're going to be creating more grammars
> anyway. Part of making it easy is to make it possible to build a lexer/parser
> as a "black box", without having to ever look at the ANTLR-generated code.

No need to go into a long conversations about this, but placing the
messages in a collection would then just hide them away. So, they would
just sit there and the users would not even know there WERE any
messages. So, then you have to supply... errr... a method to print them
out. Then you have to override that method to print them out in the way
you want. Then one finds that the information in the collection isn't
quite what you want, or that most people want the messages to print as
they occur, so now there are two methods that you might need to
override. So, you are back to square one, or maybe worse. In short,
while I don't think that collection the messages is bad idea at all (I
do it myself), my feeling is that creating the collection would actually
complicate things for new users, not simplify them. 

At the end of the day though, if that's what most people wanted and Ter
thought it to be a reasonable request, then I certainly would not object
to it.

Jim


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080701/a7b630a5/attachment.html 


More information about the antlr-interest mailing list