[antlr-interest] Inherit grammar and specify base scanner class at the same time

Ric Klaren ric.klaren at gmail.com
Thu Jan 26 01:47:31 PST 2006


Hi,

On 1/25/06, Stanimir Stamenkov <stanio at myrealbox.com> wrote:
> /Stanimir Stamenkov/:
>
> > I've first tried
> > specifying the scanner class on the super grammar as:
> >
> > class SuperLexer extends Lexer("name.stanio.MyScanner");
> >
> > but the generated "MyLexer" was direct subclass of |antlr.CharScanner|
>
> I can't manage to make it whatever I'm trying. :-1  I run:
>
> antlr superlexer.g
> antlr -glib superlexer.g mylexer.g
>
> The generated "SuperLexer.java" extends |name.stanio.MyScanner| but
> "MyLexer.java" extends |antlr.CharScanner|, and if I specify:
>
> class MyLexer extends SuperLexer("name.stanio.MyScanner");
>
> the ANTLR tool reports an error. Could someone point me if it is a
> FAQ or well documented feature as I haven't been able to find more
> info on it.

I would not be surprised if this is a bug. The inheritance thing isn't
the prettiest in the world. If you have to add/change a lot of action
code in the sub grammar then it's usually pretty much useless anyway.
(although some people seem to be happy with using it)

Cheers,

Ric


More information about the antlr-interest mailing list