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

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


On Tue, Apr 10, 2007 at 02:01:31PM +0200, Johannes Luber wrote:
> I have to load a few files to initialize some variables at the beginning
> of the parsing, but I'm not sure where to put this code. As I need to do
> execute this code only once, I've looked for an action similar to
> @members, but didn't found it.

How about putting a (dirty dirty!) instance initialiser block into
@members?

i.e.,

  @members {
    {
      ...init statements here...
    {
  }

That'll confuse anyone who looks at the grammar :)


ta,
dave

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


More information about the antlr-interest mailing list