[antlr-interest] Antlr Bug?
Gary Bennett
gbennett at requisoft.co.uk
Thu May 19 04:36:11 PDT 2005
There may be a problem with the c# code generator.
I have been having problems with this grammar: It generates files but
they won't run.
## Grammar Start ##
options {
language = "CSharp";
}
class TestParser extends Parser ;
options {
buildAST = true; // uses CommonAST by default
}
name: n:NAME
{ Console.WriteLine(" Name: {0}", n.getText() ); }
;
class TestLexer extends Lexer;
WS : (' '
| '\t'
| '\n'
| '\r')
{ $setType(Token.SKIP); }
;
NAME: 'a'
;
## Grammar End ##
In the generated c# code you get this:
static public void initializeASTFactory( ASTFactory factory )
{
factory.setMaxNodeType(5);
}
But this leads to an argument exception - it doesn't like the 5 at all.
Change the 5 to a 6 manually and it works!
Assuming that the c# code generator is ok then what should I have done
to the grammar to have ended up with a 6 in the call instead of a 5!
--------------------------------------------
Regards
Gary Bennett
Software Developer
Requisoft plc
--------------------------------------------
More information about the antlr-interest
mailing list