Re: how to get left hand side symbol in action

Christian Schoenebeck <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <5665523.qXVAcERpG2@silver>
On Montag, 8. Juni 2020 07:46:27 CEST Akim Demaille wrote:
> Hi Christian,
> 
> CC'd to help-bison FTR.
> 
> > Le 7 juin 2020 à 18:17, Christian Schoenebeck <[email protected]>
> > a écrit :
> > 
> > Hi Akim,
> > 
> > I just realized that you removed YYTERROR from Bison.
> 
> YYTERROR was not a documented feature.  I'm curious: how did you use it?

I need it for the auto completion feature that we discussed before and which I
am using as parser injected code in some projects here and there, e.g.:

http://svn.linuxsampler.org/cgi-bin/viewvc.cgi/linuxsampler/trunk/src/network/lscp.y?revision=3054&view=markup#l1605

I received reports that the missing YYTERROR macro (weird macro name BTW) in
Bison 3.6.x recently caused compilation errors due to this.

> Bison 3.6 introduce symbol kinds, e.g., for Bison itself:
> 
> enum yysymbol_kind_t
> {
>   YYSYMBOL_YYEMPTY = -2,
>   YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
>   YYSYMBOL_YYerror = 1,                    /* error  */
>   YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
>   YYSYMBOL_STRING = 3,                     /* "string"  */
>   YYSYMBOL_TSTRING = 4,                    /* "translatable string"  */
>   YYSYMBOL_PERCENT_TOKEN = 5,              /* "%token"  */
>   YYSYMBOL_PERCENT_NTERM = 6,              /* "%nterm"  */
>   YYSYMBOL_PERCENT_TYPE = 7,               /* "%type"  */
> 
> 
> so something like this should help supporting both:
> 
> #ifndef YYTERROR
> # define YYTERROR YYSYMBOL_YYerror
> #endif
> 
> Unfortunately it sends the present into the past instead of the converse. 
> Alternatively
> 
> #ifdef YYTERROR
> # define YYSYMBOL_YYerror YYTERROR
> #endif

Sounds like a plan to me!

> or something like that, should allow you to use the public interface with
> earlier versions of Bison.
> > As I have to preserve backward compatibility to older Bison versions, that
> > hard change is exactly Bison >= 3.6.0, correct?
> 
> Yup.  What is your current requirement?

Actually that ifdef solution should be enough to fix the current compiler
error with Bison >= 3.6.0, so fortunately that avoids Bison version checks.

Thanks Akim!

Best regards,
Christian Schoenebeck
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.