[antlr-interest] deriving from ANTLR class

J.R Karthikeyan jrk1987 at yahoo.co.in
Fri Aug 27 12:56:04 PDT 2010


Hi,

   I want to do callback in the custom code block instead of hardcode. Say for 
eg conside I have this rule in my grammar

statements : statement statements EOF {xxxxxx}
                  | statement EOF                 {yyyyy}
            
where xxxxxxx and yyyyyyy are some code in c that is doing some work. Instead of 
doing like this I would like to do like

statements : statement statements EOF 
{ANTLR_base_class->match("statements",...)}
                  | 
statement EOF                  {ANTLR_base_class->match("statement",...)}

Where ANTLR_base_class is some class in ANTLR and say match is virtual function. 
Now i can derive from this base class and I can write my own code. Is it 
possible to do like this in ANTLR for target language c.



More information about the antlr-interest mailing list