[antlr-interest] Name Collision

Kevin Lindsey kevin at kevlindev.com
Tue Nov 23 07:22:44 PST 2004


Hello,
 
I'm just starting out with ANTLR and I've run across a name collision with
my generated C# code. When I look at the generate parser code, I see
approximately the following:
 
public  class MyParser : antlr.LLkParser
{
    ...
    public const int RBRACKET = 37;
    ...
 
    public void someRule()
    {
        ...
        Token  RBRACKET = null;
        ...
 
        switch ( LA(1) )
        {
            ...
            match(RBRACKET);
            ...
        }
}
 
The RBRACKET in the match call should use the const RBRACKET, but the local
RBRACKET is hiding that name. I can easily get around this problem by
prefixing "MyParser." to the match parameter, but I have to make this change
everytime I change the grammar, which is a lot right now :-). Is there any
way to remedy this in the code generation?
 
Thanks,
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20041123/b30afeb4/attachment.html


More information about the antlr-interest mailing list