[antlr-interest] Error reporting

Aleksi Kallio aleksi.kallio at csc.fi
Sun Jun 10 22:49:10 PDT 2007



Hello all,

I've been checking out ANTLR and planning to use it in a multi-threaded 
server scenario. I see that ErrorManager has been written mostly with a 
single-threaded scenario in mind. There are a couple of issues I've 
stumbled into when trying to adapt ANTLR into our case.

1) ErrorManager does support per-thread error listeners. However in our 
case we are pooling the threads we use to do all the work. I believe the 
approach in ErrorManager will work, but does introduce some ambiguity. 
Currently ErrorManager collects errors into a single spot and 
redistibutes them. It would be nice if in future you could also have 
independent listeners for each parse, and could pass them from thread to 
thread without worries.

2) In ErrorManager there is this static constructor that's causing a bit 
of a headache. Our locale is "FI" for which there are no error messages 
available. So I get an error saying that we are falling back to "US" 
error messages. Because this happens in the static constructor, there is 
no way of preventing it by setting ErrorManager's locale to "US" manually:

static {
   ...
   // it is inefficient to set the default locale here if another
   // piece of code is going to set the locale, but that would
   // require that a user call an init() function or something.  I prefer
   // that this class be ready to go when loaded as I'm absentminded ;)
   setLocale(Locale.getDefault());
   ...
}

Is there a way to get around this? I would want the parser to be silent 
and all error reporting to happen through our framework.


Finally, thanks for the great software! I hope in future it also 
stretches effortlessly into less conventional server side scenarios... :)


--
Aleksi Kallio, Application Architect, Scientific Software Development
P.O. BOX 405, 02101 Espoo, Finland, Tel +358 9 457 2297
CSC is the Finnish IT center for science, www.csc.fi
e-mail: aleksi.kallio at csc.fi



More information about the antlr-interest mailing list