Re: Redefining the literal string associated to the YYerror symbol

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi Daniele,

> Le 18 juin 2020 à 19:20, Akim Demaille <[email protected]> a écrit :
> 
>> However I have a ton of tests that expect the lexer to emit a
>> "LEX_ERROR" token on error and I am considering to use YYerror special
>> token to report errors instead. Thus the question if I can rename
>> YYerror from "error" to "LEX_ERROR".
>> 
>> The fix is rather easy:
>> 
>> const char* token_name(int token)
>> {
>>   if (token == YYerror)
>>       return "LEX_ERROR";
>>   return yysymbol_name(YYTRANSLATE(token));
>> }
> 
> It looks reasonable.

Actually, why do you check the token name rather than the token kind itself?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.