[antlr-interest] Bug with C++ charVocabulary option
Ric Klaren
klaren at cs.utwente.nl
Fri May 31 02:08:39 PDT 2002
Hi,
Should have scanned my whole mailbox before answering previous mail :P
On Thu, May 30, 2002 at 04:50:26PM -0600, Trey Spiva wrote:
> el fits in the range of the vocabulary. When el is cast to unsigned int the
> value becames
> 42949667189 and fails the test. So, BitSet::member return that the
> character is not in
> the charVocabulary.
>
> When BitSet::member is change to look like
>
> bool BitSet::member(int el) const
> {
> unsigned char tempEL = (unsigned char)el;
> if ( tempEL < 0 || static_cast<unsigned int>(tempEL) >= storage.size())
> return false;
>
> return storage[tempEL];
> }
Change it to:
bool BitSet::member(unsigned int el) const
{
if ( el >= storage.size())
return false;
return storage[el];
}
Also the add method:
void BitSet::add(unsigned int el)
{
if( el >= storage.size() )
storage.resize( el+1, false );
storage[el] = true;
}
Hmmmm basically the complete LA(x) traject needs to be made unsigned int,
else we'll keep on having sign extension issues. It's something I already
noted as potential trouble. Your probably the first to really stumble on
it. Another approach is maybe adding a & 0xFF in a few places to strip away
sign extenstions....
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
Human beings, who are almost unique in having the ability to learn
from the experience of others, are also remarkable for their apparent
disinclination to do so. --- Douglas Adams, Last Chance to See
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list