[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison Error reporting
From: |
Hans Aberg |
Subject: |
Re: Bison Error reporting |
Date: |
Sat, 30 Dec 2000 20:20:33 +0100 |
At 15:19 +0100 0-12-14, Akim Demaille wrote:
>> - If Bison encounters an undefined token it calls it
>> "$undefined.", usually a sporadic character from the lexer. Is
>> it easy to make the error reporting instead writing out which
>> character this is? (Apart from defining a token for every
>> character.)
>
>Good question. The problem is you can't really assume you can print
>an unknown token as a char. Someone might return 424242 in the
>scanner, and then? What can we do?
Actually, with the Yacc-compatible (non-raw) mode, code numbers start at
257, so it means that 1-256 must be a character code.
So it is possible to always issue an error "unknown character ..." for
codes 1-256.
By the way, it is sort of funny that 0 (= YYEOF) is allowed as
"end-of-lexing", making character code 256 = '\0'. Would it not be better
letting YYEOF = -1, and allow only values < 0 be "end-of-lexing"?
Hans Aberg