[antlr-interest] Custom AST Node

Scott Amort jsamort at gmail.com
Fri Aug 4 10:04:33 PDT 2006


Hi Henry,

Henry Butowsky wrote:
>  What about if I wrote my own versions of
>   getFirstChild(),getNextChild(),getNextSibling(),
>       but changed the names slightly e.g in my derived class thus 
> avoiding the
>   "virtual contract" with the base class ?
> 
>   gFirstChild(), gNextChild() gNextSibling()

Yes, that would work, but it is a bit messy.  You would need something like:

RefncoAST
ncoAST::getNcoFirstChild() const
{
   return static_cast<RefncoAST>(antlr::BaseAST::getFirstChild());
}

You can't really avoid the cast, but you can limit the number of times 
you have to write it!

Best,
Scott


More information about the antlr-interest mailing list