[antlr-interest] Architectural Suggestion: Pluggable ErrorReporting
Vladimir Gusev
vgusev at graphlogic.com
Wed Apr 25 13:32:02 PDT 2007
As far as I remember, the error output behaviour is overridable via grammar
file. This is how I do it in the parser part:
....
private ErrorReporter errorReporter;
public CalcParser(TokenStream lexer, ErrorReporter errorReporter) {
this(lexer, 4);
this.errorReporter = errorReporter;
}
public void reportError(RecognitionException e) {
errorReporter.reportError(e.getMessage(),
e.getLine(),
e.getColumn());
}
}
.....
ErrorReporter is a simple adapter which does arbitrary error output.
Vladimir
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of David Holroyd
Sent: Wednesday, April 25, 2007 3:28 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Architectural Suggestion: Pluggable
ErrorReporting
On Wed, Apr 25, 2007 at 02:30:46PM -0400, Marc-Andr? Laverdi?re wrote:
> Maybe the error reporting logic could be delegated to an overridable
> BaseErrorDisplayer class. The BaseRecognizer would have a set/get pair
> to deal with it. It would not have much performance overhead and would
> give us some customization for people like me who would like to report
> directly to a GUI.
+1
Though I'd go for ErrorDisplayer interface, and maybe an
ErrorDisplayer.DEFAULT instance that sends to stderr, as currently.
ta,
dave
--
http://david.holroyd.me.uk/
More information about the antlr-interest
mailing list