[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Character error not reported
From: |
Akim Demaille |
Subject: |
Re: Character error not reported |
Date: |
Tue, 18 Jun 2019 11:26:49 +0200 |
[Resent, thanks Uxio]
Hi Hans,
> Le 17 juin 2019 à 15:12, Hans Åberg <address@hidden> a écrit :
>
> When a byte with high bit set that is not used in the grammar, the parser
> generated by Bison 3.4.1, does not report an error, only if the high bit is
> not set.
This is hard to believe. I suspect your problem is elsewhere.
> This occurs if one sets a Flex default rule
> . { return yytext[0]; }
> and the lexer finds a stray UTF-8 byte.
I would say that here, you return a char (yytext[0]) with "a high bit set", on
an architecture where char is signed, so you are actually returning a negative
int (when the 8th bit is set). And for Bison, any negative token number stands
for end-of-file.
You should actually write:
. { return (unsigned char) yytext[0]; }
Cheers!