[antlr-interest] Access to lexer warning/error messages after parsing
darach at gmail.com
Tue Jul 1 13:41:02 PDT 2008
For an IDL compiler I wrote years ago (using JavaCC I think) I used
subject/observer to catch/store errors
in a data structure and a degenerate visitor to format them for output and
for asserting actual/expected errors/warnings
for destructive unit testing.
It turned out to be very useful during development and testing and forced me
the quality of error messages being produced.
If a standard error mechanism / data structure were added then support in
would be a useful related enhancement.
On Tue, Jul 1, 2008 at 9:25 PM, Andy Tripp <antlr at jazillian.com> wrote:
> 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
> then ANTLR can call toString() on that and send to stderr, as it does
> ...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
> ANTLR would supply that, as it does today.
> Then you have to override that method to print them out in the way you
> 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
> 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
> 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
> The situation is analogous to Java stack traces.
> At first, the JVM would just spit out the stack trace as text on an
> Now, it does the same thing, but also gives the programmer the ability to
> access the stack trace as a data structure.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest