bug-bison
[Top][All Lists]
Advanced

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

Re: EOF redefinition (3.5->3.6 error)


From: Egor Pugin
Subject: Re: EOF redefinition (3.5->3.6 error)
Date: Fri, 12 Jun 2020 18:06:09 +0300

Hi Akim,

> Egor, could you please check that the appended commit does fix the issue for 
> you?

Sorry, can't test it.
I do not have enough resources and automation tools to quickly replace
existing bison with manually compiled from your tarballs on those
systems.
(But I'm working on better automation there!)

I've added 1) workaround, so 3.6 works for me now.
https://github.com/egorpugin/primitives/blob/master/src/version/src/range.ll#L19

I'll remove it when a new version is available and report back if
there are any issues.

On Fri, 12 Jun 2020 at 09:06, Akim Demaille <akim@lrde.epita.fr> wrote:
>
> Hi Egor,
>
> Thanks for the report!
>
> > Le 11 juin 2020 à 17:15, Egor Pugin <egor.pugin@gmail.com> a écrit :
> >
> > The reason:
> > At the end of bison generated header there is
> > #undef EOQ
> > #define EOQ yy_range::parser::token::EOQ
>
> I'm sorry about this :(  These directives are made at the wrong place, they 
> are "too visible". I've addressed that below.
>
> > Possible solutions for me:
> > 1) #undef EOQ in flex file again (after bison undef)
>
> This is the right fix.
>
> > 2) Rewrite line from return MAKE(EOQ); to return EOQ;
>
> No, don't do that.  Currently glr.cc being simply a wrapper around glr.c, we 
> have to expose the C++ names to the C parser, so you should not depend on 
> these names.  The good news is that the rewriting of glr.cc is not stuck, 
> Valentin made progress.  I intend to have the rewriting be the focus of 3.8, 
> once we are done with Vincent's work for 3.7.
>
> Egor, could you please check that the appended commit does fix the issue for 
> you?  For convenience, you can find a packaged bison here:
>
> https://www.lrde.epita.fr/~akim/private/bison/bison-3.6.3.2-b299e.tar.gz
> https://www.lrde.epita.fr/~akim/private/bison/bison-3.6.3.2-b299e.tar.xz
>
> Thanks in advance!
>
> Cheers!
>
> commit b299ea47859395be3001c9d924f5534d866805ae
> Author: Akim Demaille <akim.demaille@gmail.com>
> Date:   Fri Jun 12 07:28:05 2020 +0200
>
>     glr.cc: don't leak glr.c/glr.cc scaffolding to the user
>
>     Until we have a decent reimplementation of glr.cc, we have to use
>     tricks to shoehorn C++ symbols to the C engine of glr.c.  Some of them
>     are done via #define.  Unfortunately in Bison 3.6 some of these we
>     done in the header file, which broke valid user code.
>
>     Reported by Egor Pugin.
>     https://lists.gnu.org/r/bug-bison/2020-06/msg00003.html
>
>     * data/skeletons/glr.cc: Stop playing tricks with b4_pre_epilogue.
>     (b4_glr_cc_setup, b4_glr_cc_cleanup): New.
>     Much cleaner way to instal glr.cc's scaffolding around glr.c.
>     * data/skeletons/glr.c: Adjust to use them.
>
> diff --git a/TODO b/TODO
> index 56608dd9..a41aa4b7 100644
> --- a/TODO
> +++ b/TODO
> @@ -1,4 +1,7 @@
>  * Bison 3.7
> +** glr.cc
> +Get rid of global_tokens_and_yystype.
> +
>  ** Bistromathic
>  - Hitting tab on a line with a syntax error is ugly
>
> @@ -148,6 +151,9 @@ Les catégories d'avertissements incluent :
>  Line -1 and -3 should mention CATEGORIE, not CATEGORY.
>
>  * Bison 3.8
> +** Rewrite glr.cc
> +Get rid of scaffolding in glr.c.
> +
>  ** Unit rules / Injection rules (Akim Demaille)
>  Maybe we could expand unit rules (or "injections", see
>  https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
> diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
> index c5074a3e..76d7327b 100644
> --- a/data/skeletons/glr.c
> +++ b/data/skeletons/glr.c
> @@ -230,7 +230,9 @@ b4_copyright([Skeleton implementation for Bison GLR 
> parsers in C],
>
>  ]b4_defines_if([[#include "@basename(]b4_spec_header_file[@)"]],
>                 [b4_shared_declarations])[
> -]b4_declare_symbol_enum[
> +
> +]b4_glr_cc_if([b4_glr_cc_setup],
> +              [b4_declare_symbol_enum])[
>
>  /* Default (constant) value used for initialization for null
>     right-hand sides.  Unlike the standard yacc.c template, here we set
> @@ -2731,7 +2733,7 @@ m4_if(b4_prefix, [yy], [],
>  #define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
>  #define yylloc  ]b4_prefix[lloc]])])[
>
> -]m4_ifdef([b4_pre_epilogue], [b4_pre_epilogue])[]dnl This is a hack for 
> glr.cc.  To remove when we have a better glr.cc.
> -b4_percent_code_get([[epilogue]])[]dnl
> +]b4_glr_cc_if([b4_glr_cc_cleanup])[
> +]b4_percent_code_get([[epilogue]])[]dnl
>  b4_epilogue[]dnl
>  b4_output_end
> diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc
> index 95053a2f..658b9f20 100644
> --- a/data/skeletons/glr.cc
> +++ b/data/skeletons/glr.cc
> @@ -105,12 +105,6 @@ yyerror (]b4_locations_if([[const 
> ]b4_namespace_ref::b4_parser_class[::location_
>           ]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
>           ])[const char* msg);]])[
>
> -]b4_percent_define_flag_if([[global_tokens_and_yystype]], [],
> -[m4_define([b4_pre_epilogue],
> -[[/* The user is using the C++ token kind, not the C one. */
> -#undef ]b4_symbol(0, [id])
> -])])[
> -
>  # Hijack the epilogue to define implementations (yyerror, parser member
>  # functions etc.).
>  ]m4_append([b4_epilogue],
> @@ -222,6 +216,53 @@ b4_namespace_close[]dnl
>  ])
>
>
> +# b4_glr_cc_setup
> +# ---------------
> +# Setup redirections for glr.c: Map the names used in c.m4 to the ones used
> +# in c++.m4.
> +m4_define([b4_glr_cc_setup],
> +[[#undef ]b4_symbol(-2, [id])[
> +#define ]b4_symbol(-2, [id])[ 
> ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[
> +#undef ]b4_symbol(0, [id])[
> +#define ]b4_symbol(0, [id])[ 
> ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[
> +#undef ]b4_symbol(1, [id])[
> +#define ]b4_symbol(1, [id])[ 
> ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(1, [id])[
> +
> +#ifndef ]b4_api_PREFIX[STYPE
> +# define ]b4_api_PREFIX[STYPE 
> ]b4_namespace_ref[::]b4_parser_class[::semantic_type
> +#endif
> +#ifndef ]b4_api_PREFIX[LTYPE
> +# define ]b4_api_PREFIX[LTYPE 
> ]b4_namespace_ref[::]b4_parser_class[::location_type
> +#endif
> +
> +typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type 
> yysymbol_kind_t;
> +#define ]b4_symbol_prefix[YYEMPTY  
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
> +#define ]b4_symbol_prefix[YYerror  
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYerror
> +#define ]b4_symbol_prefix[YYEOF    
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
> +#define ]b4_symbol_prefix[YYUNDEF  
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
> +]])
> +
> +
> +# b4_glr_cc_cleanup
> +# -----------------
> +# Remove redirections for glr.c.
> +m4_define([b4_glr_cc_cleanup],
> +[b4_percent_define_flag_if([[global_tokens_and_yystype]], [],
> +[[#undef ]b4_symbol(-2, [id])[
> +#undef ]b4_symbol(0, [id])[
> +#undef ]b4_symbol(1, [id])[
> +]])[
> +
> +#undef ]b4_api_PREFIX[STYPE
> +#undef ]b4_api_PREFIX[LTYPE
> +
> +#undef ]b4_symbol_prefix[YYEMPTY
> +#undef ]b4_symbol_prefix[YYerror
> +#undef ]b4_symbol_prefix[YYEOF
> +#undef ]b4_symbol_prefix[YYUNDEF
> +]])
> +
> +
>  # b4_shared_declarations(hh|cc)
>  # -----------------------------
>  # Declaration that might either go into the header (if --defines, $1 = hh)
> @@ -339,33 +380,11 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
>  ])[
>  ]b4_namespace_close[
>
> -]dnl Map the name used in c.m4 to the one used in c++.m4.
> -[#undef ]b4_symbol(-2, [id])[
> -#define ]b4_symbol(-2, [id])[ 
> ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(-2, [id])[
> -#undef ]b4_symbol(0, [id])[
> -#define ]b4_symbol(0, [id])[ 
> ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(0, [id])[
> -#undef ]b4_symbol(1, [id])[
> -#define ]b4_symbol(1, [id])[ 
> ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(1, [id])[
> -
> -#ifndef ]b4_api_PREFIX[STYPE
> -# define ]b4_api_PREFIX[STYPE 
> ]b4_namespace_ref[::]b4_parser_class[::semantic_type
> -#endif
> -#ifndef ]b4_api_PREFIX[LTYPE
> -# define ]b4_api_PREFIX[LTYPE 
> ]b4_namespace_ref[::]b4_parser_class[::location_type
> -#endif
> -
> -]m4_define([b4_declare_symbol_enum],
> -[[typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type 
> yysymbol_kind_t;
> -#define ]b4_symbol_prefix[YYEMPTY  
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEMPTY
> -#define ]b4_symbol_prefix[YYerror  
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYerror
> -#define ]b4_symbol_prefix[YYEOF    
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYEOF
> -#define ]b4_symbol_prefix[YYUNDEF  
> ]b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol_prefix[YYUNDEF
> -]])[
>  ]b4_percent_code_get([[provides]])[
>  ]m4_popdef([b4_parse_param])dnl
> -])
> +])[
>
> -b4_defines_if(
> +]b4_defines_if(
>  [b4_output_begin([b4_spec_header_file])
>  b4_copyright([Skeleton interface for Bison GLR parsers in C++],
>               [2002-2015, 2018-2020])[
>
>


-- 
Egor Pugin



reply via email to

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