[antlr-interest] Name Collision

Terence Parr parrt at cs.usfca.edu
Tue Nov 23 09:31:56 PST 2004



On Nov 23, 2004, at 7:22 AM, Kevin Lindsey wrote:
> 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?

Hmm...that seems like a bug to me; not sure how anything could compile. 
  What was the input?  If you did

RBRACKET:RBRACKET

or something, you'd see this.

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list