[antlr-interest] C# Bug in CharScanner

Micheal J open.zone at virgin.net
Wed Jun 8 02:33:57 PDT 2005


Thanks Dr. Kocker. My apologies for the dealy in repsonding to your report.
 
This is indeed an issue with ANTLR/C# and will be fixed in the next 2.x
release.
 
Cheers,
 
Micheal

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Dr. Hartmut Kocher
Sent: 31 May 2005 22:57
To: antlr-interest at antlr.org
Subject: [antlr-interest] C# Bug in CharScanner



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/20050608/4cf612e7/attachment-0001.html


More information about the antlr-interest mailing list