[antlr-interest] Where to put general intialisation logic for a parser?

David Holroyd dave at badgers-in-foil.co.uk
Tue Apr 10 15:58:41 PDT 2007


On Tue, Apr 10, 2007 at 11:55:08PM +0200, Johannes Luber wrote:
> David Holroyd wrote:
> > How about putting a (dirty dirty!) instance initialiser block into
> > @members?

> > That'll confuse anyone who looks at the grammar :)
> 
> Guaranteed! I had to look up, what instance initialisers were because I
> haven't used them myself.

I only know about this Java feature from having seen that the 'static'
is optional, while reading some grammar or other.  I've never used it,
other then to prove to myself that javac actually accepts the syntax :)

Anyway, a more basic option; just add some setter-methods and use a
'builder' pattern to obtain parser instances?  Might be easier to write
unit tests that way...

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list