[antlr-interest] Using an AST Type with a TreeParser
Allan Brock
brockallan at gmail.com
Fri Oct 30 09:34:23 PDT 2009
I'm replacing the AST type with MyAST (based on the treewalk example in
antlr2.7.6) in order to get line numbers. I've gotten everything to work,
but have run into a couple problems that I used to a casts to overcome. I'm
wondering if there is a simpler answer.
In my application, the Parser produces an AST using type MyAST. This is
walked by a TreeParser (MyTreeParser) that also produces an AST using type
MyAST. Everything seems fine with the parser.
But in MyTreeParser is had to add:
public:
virtual void program(ANTLR_USE_NAMESPACE(
antlr)RefAST _t)
{
program((RefMyAST)_t);
}
Note the cast from RefAST to RefMyAST. If I don't do this, I get a
compilation error.
void antlr::TreeParser::program(antlr::RefAST)' : is abstract
Is what I did to get around this reasonable? Or is there a better way.
After this, I also hit another problem requiring me to add the following to
MyAST.hpp:
virtual void initialize( ANTLR_USE_NAMESPACE(antlr)RefAST ast )
{
initialize((RefMyAST) ast);
}
Note the cast. Anyone have similar problems?
Allan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091030/35eef934/attachment.html
More information about the antlr-interest
mailing list