Re: Parsing '\x00' -- appears to be the only thing preventing parsing binary data

Akim Demaille <[email protected]> Thu, 1 Apr 2021 18:12:09 +0200
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi all,

>> On 4/1/21 16:28, Stephen Taylor via Users list for the GNU Bison parser generator wrote:
>>> Thanks, that seems to get around \x00 -- unfortunately, the same issue then reappears with the values \x80 - \xff … I could special case every single value e.g.
>>> \x00 {return ZERO; }
>>> \x80 { return X80; }
>>> \x81 { return X81; }
>>> :
>>> \xff { return XFF; }
>>> . | \n  { return *yytext; }
>>> But seems a bit clumsy. Any thoughts?


>> On Apr 1, 2021, at 11:05, John P. Hartmann <[email protected]> wrote:
>> 
>> Write your own scanner in C.

FWIW, I agree with that statement.


There is no reason at all for \x80... to be special.  Unless you return a char, which is probably a signed char, so what you think is 255 is actually -128.  Make sure your types are right.  Just call your scanner by hand and printf %d what you get.