help-bison
[Top][All Lists]
Advanced

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

Re: how to get left hand side symbol in action


From: Derek Clegg
Subject: Re: how to get left hand side symbol in action
Date: Fri, 10 May 2019 06:57:00 -0700

On May 10, 2019, at 5:21 AM, Hans Åberg <address@hidden> wrote:
> 
> 
>> On 10 May 2019, at 07:24, Akim Demaille <address@hidden> wrote:
>> 
>>> In practice you just need the symbol name as is. Nobody needs the 
>>> translation,
>> 
>> I beg to disagree.  Nobody should translate the keyword "break",
>> but
>> 
>>> # bison /tmp/foo.y
>>> /tmp/foo.y:1.7: erreur: erreur de syntaxe, : inattendu, attendait char ou 
>>> identifier ou <tag>
>>>   1 | %token: FOO
>>>     |       ^
>> 
>> looks stupid; "char", "identifier" and "<tag>" should be translated.
> 
> I think it should only output whatever is in the yytname_ table. Does not the 
> translation taking place dynamically of that in the error message?

I don’t think it’s worthwhile for bison to support internationalization in the 
generated parser.

In fact, I do not think error messages in the generated parser should be 
provided by bison, except as a trivial default. Instead, I’d like to see bison 
call a function (which I provide) when a syntax error occurs, with a list of 
what was expected along with what was encountered. Obviously, they should be 
provided without translation. That would be the most flexible.

BTW, I suggested this in a message dates 6 Feb 2019, with more details, about 
what such an API might look like.

Derek






reply via email to

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