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: Christian Schoenebeck
Subject: Re: how to get left hand side symbol in action
Date: Mon, 08 Jun 2020 13:32:07 +0200

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 <schoenebeck@crudebyte.com>
> > 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





reply via email to

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