Re: how to get left hand side symbol in action

Derek Clegg <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
On May 10, 2019, at 5:21 AM, Hans Åberg <[email protected]> wrote:
> 
> 
>> On 10 May 2019, at 07:24, Akim Demaille <[email protected]> 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




_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
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.