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

Gavin Lambert antlr at mirality.co.nz
Wed Jul 2 14:15:17 PDT 2008


At 19:30 2/07/2008, Sam Ellis wrote:
 >The approach I used in my grammar was to define an 
IErrorReporter
 >interface, and to pass an object that implements this interface
 >to both the lexer and parser. The parser then calls this 
interface
 >when an error occurs, and I have some custom logic in the lexer
 >that checks for illegal chars and reports these too (but does 
not
 >throw an exception because I want it to continue). The same 
object
 >is also used elsewhere in my code for reporting other errors. I
 >have an implementation of this interface for reporting to 
stderr,
 >and another implementation that stores the errors in a data
 >structure (ultimately for consumption by Eclipse) and a null
 >implementation that just throws errors away.

Sounds good to me.  The Strategy pattern is usually a good choice 
for implementing pluggable functionality :)

Any chance you could Wiki your solution for others to use?  And 
maybe even get it incorporated into a future version of the 
runtime?



More information about the antlr-interest mailing list