help-bison
[Top][All Lists]
Advanced

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

Re: Token value in custom error reporting


From: Hans Åberg
Subject: Re: Token value in custom error reporting
Date: Thu, 18 Jun 2020 14:54:13 +0200

> On 18 Jun 2020, at 10:24, Daniele Nicolodi <daniele@grinta.net> wrote:
> 
> On 18/06/2020 00:39, Akim Demaille wrote:
>> 
>> Would you have an example of what you mean?
>
> In the existing code, on error the lexer emits a LEX_ERROR token. This
> results in a grammar error that triggers error recovery (good) but also
> in an extra error emitted by Bison (bad). Right now the code checks the
> error messages in yyerror() and suppresses the unwanted error reporting
> if it contains the string "LEX_ERROR”.

In my C++ parser, the lexer has rule
.          { return my_parser::token::token_error; }

When it is triggers, I get the error:
  <file>:21.1: error: syntax error, unexpected token error

It might be nicer to actually write out this token, though.





reply via email to

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