Re: [PATCH 1/2] glr2.cc: fork glr.cc to a c++ version

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
> Le 30 août 2020 à 11:01, Akim Demaille <[email protected]> a écrit :
> 
> One of the issues you should address very early is that you still pass
> yyparser as if it were a user param in many places, although you already
> have it as a member of your objects.  So I get conflicts such as:

As a first step, I suggest this patch.  If you have not started
yet your own fixes.
0001-glr2.cc-fix-a-few-warnings.patch (application/octet-stream, 5.7 KB)
From b63e3a3352ea13074c5491e40f92b40ce0552004 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[email protected]>
Date: Sun, 30 Aug 2020 12:01:23 +0200
Subject: [PATCH] glr2.cc: fix a few warnings

* data/skeletons/glr2.cc: Fix some documentation.
Be consistent between class/struct.
(yydoAction, yyresolveAction): Avoid passing yyparser where useless.
---
 data/skeletons/c.m4    |  2 +-
 data/skeletons/glr2.cc | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 894af042..c41db4d1 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -130,7 +130,7 @@ m4_define([b4_user_args],
 [m4_ifset([b4_parse_param], [, b4_user_args_no_comma])])
 
 # b4_user_args_no_comma
-# ------------
+# ---------------------
 m4_define([b4_user_args_no_comma],
 [m4_ifset([b4_parse_param], [b4_args(b4_parse_param)])])
 
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index dbdc84e5..09f70e92 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -355,7 +355,7 @@ class StrongIndexAlias
     /// \brief Reclaim the memory associated to a symbol.
     /// \param yymsg     Why this token is reclaimed.
     ///                  If null, print nothing.
-    /// \param yysym     The symbol.
+    /// \param yykind    The symbol kind.
     void yy_destroy_ (const char* yymsg, symbol_kind_type yykind,
                       const semantic_type* yyvaluep]b4_locations_if([[,
                       const location_type* yylocationp]])[);
@@ -850,7 +850,7 @@ typedef int yyRuleNum;
 typedef short yyItemNum;
 
 // Forward declarations.
-struct yyGLRState;
+class yyGLRState;
 struct yySemanticOption;
 struct yyGLRStackItem;
 struct yyGLRStack;
@@ -2245,7 +2245,7 @@ struct yyGLRStack {
    *  yyerr for YYERROR, yyabort for YYABORT.  */
   YYRESULTTAG
   yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
-                YYSTYPE* yyvalp]b4_locuser_formals[)
+                YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
   {
     bool yynormal YY_ATTRIBUTE_UNUSED = !yystateStack.isSplit();
     int yylow;
@@ -2332,7 +2332,7 @@ struct yyGLRStack {
    *  for userAction.  */
   inline YYRESULTTAG
   yydoAction (yyStateSetIndex yyk, yyRuleNum yyrule,
-              YYSTYPE* yyvalp]b4_locuser_formals[)
+              YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
   {
     int yynrhs = yyrhsLength (yyrule);
 
@@ -2345,7 +2345,7 @@ struct yyGLRStack {
         yystateStack.setFirstTop(&yystateStack[yystateStack.size() - 1].getState());
         YY_REDUCE_PRINT ((true, yyrhs, yyk, yyrule]b4_user_args[));
         return yyuserAction (yyrule, yynrhs, yyrhs,
-                             yyvalp]b4_locuser_args[);
+                             yyvalp]b4_locations_if([, yylocp])[);
       }
     else
       {
@@ -2364,7 +2364,7 @@ struct yyGLRStack {
         yystateStack.setTopAt(yyk, yys);
         YY_REDUCE_PRINT ((false, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
         return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
-                             yyvalp]b4_locuser_args[);
+                             yyvalp]b4_locations_if([, yylocp])[);
       }
   }
 
@@ -2390,7 +2390,7 @@ struct yyGLRStack {
         YYSTYPE yysval;]b4_locations_if([[
         YYLTYPE yyloc;]])[
 
-        YYRESULTTAG yyflag = yydoAction (yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
+        YYRESULTTAG yyflag = yydoAction (yyk, yyrule, &yysval]b4_locations_if([, &yyloc])[);
         if (yyflag == yyerr && yystateStack.isSplit())
           {
             YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
@@ -2590,7 +2590,7 @@ struct yyGLRStack {
     if (yymerge)
       {
         int yyprec = yydprec[yybest->yyrule];
-        yyflag = yyresolveAction (yybest, &yysval]b4_locuser_args[);
+        yyflag = yyresolveAction (yybest, &yysval]b4_locations_if([, yylocp])[);
         if (yyflag == yyok)
           for (yySemanticOption* yyp = yybest->next();
                yyp != YY_NULLPTR;
@@ -2600,7 +2600,7 @@ struct yyGLRStack {
                 {
                   YYSTYPE yysval_other;]b4_locations_if([
                   YYLTYPE yydummy;])[
-                  yyflag = yyresolveAction (yyp, &yysval_other]b4_locuser_args([&yydummy])[);
+                  yyflag = yyresolveAction (yyp, &yysval_other]b4_locations_if([, &yydummy])[);
                   if (yyflag != yyok)
                     {
                       yyparser.yy_destroy_ ("Cleanup: discarding incompletely merged value for",
@@ -2613,7 +2613,7 @@ struct yyGLRStack {
             }
       }
     else
-      yyflag = yyresolveAction (yybest, &yysval]b4_locuser_args([yylocp])[);
+      yyflag = yyresolveAction (yybest, &yysval]b4_locations_if([, yylocp])[);
 
     if (yyflag == yyok)
       {
@@ -2631,7 +2631,7 @@ struct yyGLRStack {
    *  have been destroyed (assuming the user action destroys all RHS
    *  semantic values if invoked).  */
   YYRESULTTAG
-  yyresolveAction (yySemanticOption* yyopt, YYSTYPE* yyvalp]b4_locuser_formals[)
+  yyresolveAction (yySemanticOption* yyopt, YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
   {
     yyGLRState* yyoptState = yyopt->state();
     yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
@@ -2657,7 +2657,7 @@ struct yyGLRStack {
       yylval = yyopt->yyval;]b4_locations_if([
       yylloc = yyopt->yyloc;])[
       yyflag = yyuserAction (yyopt->yyrule, yynrhs,
-                             yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyvalp]b4_locuser_args[);
+                             yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyvalp]b4_locations_if([, yylocp])[);
       yychar = yychar_current;
       yylval = yylval_current;]b4_locations_if([
       yylloc = yylloc_current;])[
-- 
2.28.0
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.