[antlr-interest] Abstract tree parser

Jim Idle jimi at temporal-wave.com
Fri Feb 26 08:17:07 PST 2010


I missed out that the implementing class should be abstract. Then you get what you ask for below. You don't want the .g file to generate an abstract class, you implement your methods in the abstract class, derive that from TreeParser, then derive your generated class from the abstract class.

Jim


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Christian Pontesegger
> Sent: Friday, February 26, 2010 3:07 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Abstract tree parser
> 
> On 25.02.2010 21:47,  Jim Idle wrote:
> > tree grammar IScriptTreeParser;
> > options {
> >    language = Java;
> >    tokenVocab = IScript;
> >    ASTLabelType = CommonTree;
> >    SuperClass = AbstractIScriptTreeParser;
> > }
> >
> 
> Still not what I'd like to have. I think I'll give it one more try:
> 
> When finished I want to have following inheritance
> 
> TreeParser <-- IScriptTreeParser <-- ConcreteTreeParser
> TreeParser <-- IScriptTreeParser <-- AnotherConcreteTreeParser
> 
> TreeParser
>     *   is the ANTLR base class
> 
> IScriptTreeParser is:
>     *    automatically generated from my treegrammar file
>     *    abstract public class IScriptCompiler extends TreeParser {...
> }
>         ----^^^
>     *    has some abstract methods defined in @members
> 
> ConcreteTreeParser is:
>     *    some class I am doing on my own
>     *    implements abstract stuff from IScriptTreeParser
> 
> AnotherConcreteTreeParser is:
>     *    some class I am doing on my own
>     *    different implementation of abstract methods
> 
> 
> so far I did not get a recommendation how to do that.
> 
> any ideas?
> Christian
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list