[PATCH 01/17] gram: more debugging information

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
* src/gram.c (ritem_print): Show indices in ritem.
---
 src/gram.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/gram.c b/src/gram.c
index cc5e54b5..58f62700 100644
--- a/src/gram.c
+++ b/src/gram.c
@@ -155,11 +155,22 @@ void
 ritem_print (FILE *out)
 {
   fputs ("RITEM\n", out);
+  bool first = true;
   for (int i = 0; i < nritems; ++i)
-    if (ritem[i] >= 0)
-      fprintf (out, "  %s", symbols[ritem[i]]->tag);
-    else
-      fprintf (out, "  (rule %d)\n", item_number_as_rule_number (ritem[i]));
+    {
+      if (first)
+        {
+          fprintf (out, "  %d: ", i);
+          first = false;
+        }
+      if (ritem[i] >= 0)
+        fprintf (out, "  %s", symbols[ritem[i]]->tag);
+      else
+        {
+          fprintf (out, "  (rule %d)\n", item_number_as_rule_number (ritem[i]));
+          first = true;
+        }
+    }
   fputs ("\n\n", out);
 }
 
-- 
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.