[PATCH 1/7] glr.cc: don't "leak" yyparse

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
When using glr.cc, the C function yyparse is an internal detail that
should not be exposed.  Users might call it by accident (I did).

* data/skeletons/glr.c (yyparse): When used for glr.cc, rename as yy_parse_impl.
* data/skeletons/glr.cc: Adjust.
---
 data/skeletons/glr.c  | 4 ++--
 data/skeletons/glr.cc | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index f1594b2f..f54d25c7 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -217,7 +217,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
 #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
 ]m4_if(b4_prefix, [yy], [],
 [[/* Substitute the variable and function names.  */
-#define yyparse ]b4_prefix[parse
+#define ]b4_glr_cc_if([yy_parse_impl], [yyparse])[ ]b4_prefix[]b4_glr_cc_if([_parse_impl], [parse])[
 #define yylex   ]b4_prefix[lex
 #define yyerror ]b4_prefix[error
 #define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
@@ -2422,7 +2422,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
 `----------*/
 
 int
-yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
+]b4_glr_cc_if([yy_parse_impl], [yyparse])[ (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
 {
   int yyresult;
   yyGLRStack yystack;
diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc
index 9677ea57..2dcff7e5 100644
--- a/data/skeletons/glr.cc
+++ b/data/skeletons/glr.cc
@@ -144,7 +144,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
   int
   ]b4_parser_class[::parse ()
   {
-    return ::yyparse (*this]b4_user_args[);
+    return ::yy_parse_impl (*this]b4_user_args[);
   }
 
 #if ]b4_api_PREFIX[DEBUG
-- 
2.29.2
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.