bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 5/8] parsers: support translatable token aliases


From: Akim Demaille
Subject: Re: [PATCH 5/8] parsers: support translatable token aliases
Date: Wed, 2 Jan 2019 12:19:53 +0100


> Le 2 janv. 2019 à 09:51, Adrian Vogelsgesang <address@hidden> a écrit :
> 
> Hi Akim,

Hi Adrian!

> nice patch series! Thanks for the great work.

You are most welcome :)

> Being able to translate token names will be definitely useful and I am 
> looking forward to using that functionality.
> 
> I just took a short glance over the patches and maybe I am missing something, 
> but:
> Where is the `_` function used by lalr1.cc defined?
> Am I supposed to put a "#define _(T) myTranslateFunc(T)" into my grammar or 
> is it already defined somewhere?

Yes, the user is in charge of providing the translation infrastructure.  We 
cannot use the one bison generates in the parsers (YY_), since they use a 
specific catalogue (= set of translations) for yyparse, which contains "parse 
error", etc.

So you have to provide a _ function, which takes a string and returns its 
translation.  In typical situations (such as bison's own parser) the remainder 
of the program has translation support, and you just have to extend it to the 
parser.  In the case of bison itself, there was nothing to do, as the parser 
already used _ for some custom messages.

I'll put all this in docs once there is some consensus on this branch and its 
alternatives.


reply via email to

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