[antlr-interest] C# Bug in CharScanner
Dr. Hartmut Kocher
hwk at cortex-brainware.de
Tue May 31 14:56:52 PDT 2005
I think I found a bug in the C# CharScanner:
The rewind() method does not take into account the case insensitive flag.
Therefore, if the scanner is rewound after a wrong prediction, it throws an
exception if the case of a case insensitive token does not match.
I think the correct implementation should be:
public virtual void rewind(int pos)
{
inputState.input.rewind(pos);
//setColumn(inputState.tokenStartColumn);
if (caseSensitive)
{
cached_LA2 = inputState.input.LA(2);
cached_LA1 = inputState.input.LA(1);
}
else
{
cached_LA2 = toLower(inputState.input.LA(2));
cached_LA1 = toLower(inputState.input.LA(1));
}
}
Kind regards
Dr. Hartmut Kocher
Cortex Brainware GmbH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050531/aa344817/attachment.html
More information about the antlr-interest
mailing list