[antlr-interest] Grammar inheritance problem
Andrey Timoshenkov
tas at ultersys.ru
Mon Jan 15 04:09:54 PST 2007
Hi All.
I have a trouble using ANTLR 2.7.5. I need 2 lexer grammars L1 and L2,
where L2 inherits from L1 and I need to specify my own base class for
resulting lexer. Below are simple examples:
L1.g:
--------------------------
options {
language="Cpp";
}
class L1 extends Lexer("MyScanner");
options {
k=2;
}
tokens {
TOK1 = "abc";
}
NUM: '0'..'9';
---------------------------------
L2.g:
---------------------------------
options {
language="Cpp";
}
class L2 extends L1("MyScanner");
options {
k=2;
}
tokens {
TOK2 = "def";
}
ID: ( 'a'..'z' ) ( 'a'..'z' | '0'..'9' )+;
---------------------------------
The second grammar fails due to the line:
class L2 extends ("MyScanner");
in generated "expandedl2.g".
If I remove ("MyScanner") from L2 definition then ANTLR processes the
grammar without errors but I lose inheritance from MyScanner.
Can somebody suggest a workaround?
Thank you in advance.
Andrey Timoshenkov, Ulter Systems Inc., Moscow, Russia.
More information about the antlr-interest
mailing list