[antlr-interest] Problems using ! in lexer with C# output
James Park
jpark at constanttime.com
Thu Mar 6 01:57:10 PST 2003
I'm having problems generating C# code that compiles when I use ! in
a lexer rule. I'm trying to figure out whether I am doing something
incorrectly or whether there is a bug in the C# generator.
I have the following rule in my lexer definition:
REFERENCE :
( '$'! (IDENTIFIER)
| "${"! (IDENTIFIER) '}'!
)
;
The C# output generated is below:
if ((LA(1)=='$') && (tokenSet_0_.member(LA(2))))
{
int _saveIndex = 0;
_saveIndex = text.Length;
match('$');
text.Length = _saveIndex;
{
mIDENTIFIER(false);
}
}
else if ((LA(1)=='$') && (LA(2)=='{'))
{
_saveIndex = text.Length;
match("${");
text.Length = _saveIndex;
{
mIDENTIFIER(false);
}
_saveIndex = text.Length;
match('}');
text.Length = _saveIndex;
}
This bit of code does not compile because there is no _saveIndex
defined in the else if block. Do I need to do something differently
in my rule or is this a bug?
thanks for any help.
jp
--
James Park
jpark at constanttime.com
http://dynamicdns.constanttime.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list