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

Terence Parr parrt at cs.usfca.edu
Tue Apr 10 12:09:00 PDT 2007


On Apr 10, 2007, at 5:01 AM, Johannes Luber wrote:

> Hello,
>
> 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. The closest I've come seems to be an
> @init action at the start rule. Unfortunately, using @init doesn't  
> seem
> right for this purpose. So I've wondered if deriving a special Parser
> class would be the right thing to do. I am right? If yes, is there
> anything I have to be aware of?

How about defining an overloaded constructor?

Ter



More information about the antlr-interest mailing list