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.
This commit is contained in:
Akim Demaille
2020-06-12 07:28:05 +02:00
parent 508ac09939
commit 3f4ffea6f2
5 changed files with 64 additions and 34 deletions

View File

@@ -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