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

Andy Tripp antlr at jazillian.com
Tue Jul 1 13:25:55 PDT 2008


Jim Idle wrote:

> No need to go into a long conversations about this, but placing the 
> messages in a collection would then just hide them away. 

What's being suggested is to have ANTLR store the error in some data structure,
then ANTLR can call toString() on that and send to stderr, as it does today.
...and then just provide access to the data structure.

> 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. 
ANTLR would supply that, as it does today.

> Then you have to override that method to print them out in the way 
> you want. 

Yes, if you want to print it in a different way (unlikely).

> Then one finds that the information in the collection isn't 
> quite what you want, 

Yes, that's always a potential problem.

> 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.

The choice is between:
today: getting a message sent to stderr, override ANTLR-generated code if that's not good enough
proposed: getting a message sent to stderr, having access to the error in
   a data structure, override ANTLR-generated code if that's not good enough

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

The situation is analogous to Java stack traces.
At first, the JVM would just spit out the stack trace as text on an exception.
Now, it does the same thing, but also gives the programmer the ability to
access the stack trace as a data structure.

Andy
 



More information about the antlr-interest mailing list