[antlr-interest] Inherit grammar and specify base scanner class at
the same time
Stanimir Stamenkov
stanio at myrealbox.com
Mon Jan 23 07:54:12 PST 2006
Hello,
I'm new to the ANTLR framework and I'm currently trying to generate
a lexer which employs grammar inheritance and specifies to be of
specific |antlr.CharScanner| subtype, at the same type. I've tried
both of these work:
class MyLexer extends SuperLexer;
or:
class MyLexer extends Lexer("name.stanio.MyScanner");
But I want the effect of both at the same time, so 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| again. Then I've tried:
class MyLexer extends SuperLexer("name.stanio.MyScanner");
but I get error:
.\expandedmylexer.g:5:23: rule classDef trapped:
.\expandedmylexer.g:5:23: expecting "Parser", found '('
error: aborting grammar 'unknown grammar' due to errors
I see line 5 in the generated "expandedmylexer.g":
class MyLexer extends ("name.stanio.MyScanner");
while normally (using the first declaration for grammar inheritance
I've pointed) in that file I see:
class MyLexer extends Lexer;
Is it possible what I'm trying?
--
Thank you in advance,
Stanimir
More information about the antlr-interest
mailing list