[antlr-interest] 8 bit ASCII and cpp source code

Jim O'Connor Jim.O'Connor at microfocus.com
Mon Jan 29 05:54:39 PST 2007


Great minds think alike?? :0)

I tried that. The 8 bit character "turns into" 0xffd8 before getting to
the critical point

Switch(0xffd8) doesn't match case(0xd8).

> -----Original Message-----
> From: Gavin Lambert [mailto:antlr at mirality.co.nz]
> Sent: Saturday, January 27, 2007 3:14 PM
> To: Jim O'Connor
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] 8 bit ASCII and cpp source code
> 
> At 10:25 27/01/2007, Jim O'Connor wrote:
> >  The charscanner and inputbuffer classes have a return type of
> > int for LA().  LA(1) returns 0Xffd8 for my "problem" character.
> >
> >Solution: change the LA() to return unsigned?  Ric hinted at such
> >in a 2004 archive note.
> 
> I haven't actually looked at the code for LA, but probably a
> simpler solution is to cast through unsigned char along the way.
> 
> ie. somewhere it'll have a bit that says "return c;" where c is a
> char (or maybe "return (int)c;" -- change that to "return
> (int)(unsigned char)c;" (or the equivalent static_casts, if you're
> that way inclined) and it should fix up your problem character
> without changing the function signature, which might be important
> if something is depending on it to return negative answers
> sometimes.
> 
> 
> 
> This message has been scanned for viruses by MailController -
> www.MailController.altohiway.com


More information about the antlr-interest mailing list