[PATCH 09/10] glr2.cc: use the same format for traces as glr.c

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
* data/skeletons/glr2.cc: here.
This allows to share the same expected output.
---
 data/skeletons/glr2.cc | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 68d114bd..ea4fa43d 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -1589,7 +1589,8 @@ class state_stack {
     int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
     int yylow = 1;])[
     int yyi;
-    std::cerr << "Reducing stack " << yyk.get() << " by rule " << yyrule - 1 << " (line " << yyrline[yyrule] << "):\n";
+    std::cerr << "Reducing stack " << yyk.get() << " by rule " << yyrule - 1
+              << " (line " << int (yyrline[yyrule]) << "):\n";
     if (! yynormal)
       yyfillin (yyvsp, 1, -yynrhs);
     /* The symbols being reduced.  */
@@ -2077,7 +2078,7 @@ public:
               {
                 state_set_index yynewStack = yystateStack.yysplitStack (yyk);
                 YY_DEBUG_STREAM << "Splitting off stack " << yynewStack.get()
-                                << " from " << yyk.get() << '\n';
+                                << " from " << yyk.get() << ".\n";
                 YYRESULTTAG yyflag =
                   yyglrReduce (yynewStack, *yyconflicts,
                                yyimmediate[*yyconflicts]);
@@ -2274,10 +2275,11 @@ public:
 
         YYRESULTTAG yyflag = yydoAction (yyk, yyrule, &yysval]b4_locations_if([, &loc])[);
         if (yyflag == yyerr && yystateStack.isSplit())
-          {
+          {]b4_parse_trace_if([[
             YY_DEBUG_STREAM << "Parse on stack " << yyk.get()
-                            << " rejected by rule #" << yyrule - 1 << ".\n";
-          }
+                            << " rejected by rule " << yyrule - 1
+                            << " (line " << int (yyrline[yyrule]) << ").\n";
+          ]])[}
         if (yyflag != yyok)
           return yyflag;
         YY_SYMBOL_PRINT ("-> $$ =", static_cast<yysymbol_kind_t>(yyr1[yyrule]), &yysval, &loc);
@@ -2296,11 +2298,11 @@ public:
             YYASSERT (yys != YY_NULLPTR);
           }
         yystateStack.yyupdateSplit (*yys);
-        state_num yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
+        state_num yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));]b4_parse_trace_if([[
         YY_DEBUG_STREAM << "Reduced stack " << yyk.get()
-                        << " by rule #" << yyrule - 1
-                        << "; action deferred.  Now in state " << yynewLRState
-                        << ".\n";
+                        << " by rule " << yyrule - 1 << " (line " << int (yyrline[yyrule])
+                        << "); action deferred.  Now in state " << yynewLRState
+                        << ".\n";]])[
         for (state_set_index yyi = create_state_set_index(0); yyi.uget() < yystateStack.numTops(); ++yyi)
           if (yyi != yyk && yystateStack.topAt(yyi) != YY_NULLPTR)
             {
-- 
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.