[antlr-interest] Name Collision
Kevin Lindsey
kevin at kevlindev.com
Tue Nov 23 09:46:57 PST 2004
Hi Terence,
>> 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?
I'm not sure if we can have attachments on this group, so I'm attaching and
inlining a .g file that recreates the problem. Note that even though some of
the content may not be relevant, it reflects what I'm using in my full
grammar. I just want to make sure you have all you need to recreate the
problem. You'll see the situation I described in the typeSpec() method.
Thanks,
Kevin
//
// Global options
//
options
{
language = "CSharp";
namespace = "Temp.Msil";
}
//
// Parser
//
class MyParser extends Parser;
options
{
k = 2;
buildAST = true;
defaultErrorHandler = false;
}
typeSpec
: className
: LBRACKET Name1 RBRACKET
: LBRACKET MODULE Name1 RBRACKET
| type
;
className
: LBRACKET Name1 RBRACKET slashedName
| LBRACKET MODULE Name1 RBRACKET slashedName
| slashedName
;
slashedName
: Name1 (SLASH Name1)*
;
type
: "class" className
| "object"
| "string"
| "value" "class" className
| "valuetype" className
| "typedref"
| "char"
| "void"
| "bool"
;
//
// Lexer
//
class MyLexer extends Lexer;
options
{
k = 3;
}
LBRACKET: '[';
MODULE: ".module" ;
Name1: (ALPHA)+ ('.' (ALPHA)+)?;
RBRACKET: ']';
SLASH: '/';
protected
ALPHA: ('_' | 'a'..'z' | 'A'..'Z' );
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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: temp.g
Type: application/octet-stream
Size: 901 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20041123/641139c3/temp.obj
More information about the antlr-interest
mailing list