[antlr-interest] How to add code to the Parser class?

Anakreon anakreonmejdi at yahoo.gr
Tue Apr 20 03:28:55 PDT 2004


jduquevieira wrote:
> To have more control over the parsing I added some Semantic 
> Predicates to my Gramar.
> 
> These predicates rely on a Variable. The Variable has to known to 
> all the rules.
> 
> How can I set this Variable as a member of the Parser class of my 
> Gramar? I don't seem to find out how, except opening the generated 
> Parser file and adding the Variable as a Member.
> 
> This way, everytime I change the Gramar and the Parser class is 
> reconstruted, I need to edit it and insert a line of code declaring 
> the Variable.
> 
> Is there any other way to do this?
> 
> Thanks a lot.
> 
> 
class MyParser extends Parser;
options {
}

//if have tokens
tokens {
}

{
private int myVar;
private String anOtherVar;
}

//rules follow


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list