[antlr-interest] Abstract tree parser

Christian Pontesegger christian.pontesegger at web.de
Wed Feb 24 11:36:01 PST 2010


 Terence Parr wrote:
> You can either define abstract methods within @members and then subclass the parser or you can create a subclass of Parser with the abstract methods or concrete methods then use superClass.
>   
Thats what I intend to do, have

@members {

    protected abstract void foo();
    ...
}

but then the generated class will have an error due to the missing
"abstract" modifier in the class definition. Unfortunately the @headers
section is pasted right before some other imports. If it were the last
before the class definition I could put my "abstract" modifier there.

I want to derive from my abstract parser and have several implementing
parsers with different functionality. Right now I am declaring dummy
methods within @members and overwrite them in my subclasses. But thats
not the way java is meant to be, right?

So if it is not possible to do that now, maybe this is some input for a
future version of ANTLR.

Christian


More information about the antlr-interest mailing list