[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Character error not reported

From: Hans Åberg
Subject: Re: Character error not reported
Date: Tue, 2 Jul 2019 14:15:00 +0200

> On 2 Jul 2019, at 07:08, Akim Demaille <address@hidden> wrote:
> Hi Hans,


>> Le 18 juin 2019 à 18:09, Hans Åberg <address@hidden> a écrit :
>> As 8-bit character tokens are not useful with UTF-8, I have replaced it with:
>> %token token_error "token error"
>> . { return my_parser::token::token_error; }
>> Please let me know if there is a better way to generate a parser error.
> I personally prefer to throw an exception.
>  .   throw parser::syntax_error(loc, "invalid character: "s + yytext);

I changed to that too, writing to make it look as though thrown by the parser:
. { throw my_parser::syntax_error(yylloc, "syntax error, unexpected my_parser 
token error.");

When the match is a part of an UTF-8 byte, it is not useful to report what it 

The token-error token may still be needed, though, as I store token values on 
the symbol table.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]