bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

style: use item_rule


From: Akim Demaille
Subject: style: use item_rule
Date: Wed, 30 Jan 2019 07:02:43 +0100

commit 45f05628bcf133f916557c1d238895f92989f48e
Author: Akim Demaille <address@hidden>
Date:   Mon Jan 28 19:26:18 2019 +0100

    style: use item_rule
    
    * src/print-graph.c, src/print-xml.c: here.

diff --git a/src/print-graph.c b/src/print-graph.c
index 3e3b7230..52952688 100644
--- a/src/print-graph.c
+++ b/src/print-graph.c
@@ -19,6 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
+#include "print-graph.h"
+
 #include "system.h"
 
 #include "closure.h"
@@ -30,7 +32,6 @@
 #include "graphviz.h"
 #include "lalr.h"
 #include "lr0.h"
-#include "print-graph.h"
 #include "reader.h"
 #include "state.h"
 #include "symtab.h"
@@ -63,12 +64,7 @@ print_core (struct obstack *oout, state *s)
   for (size_t i = 0; i < snritems; ++i)
     {
       item_number const *sp1 = ritem + sitems[i];
-      item_number const *sp = sp1;
-
-      while (0 <= *sp)
-        sp++;
-
-      rule *r = &rules[item_number_as_rule_number (*sp)];
+      rule const *r = item_rule (sp1);
 
       obstack_printf (oout, "%3d ", r->number);
       if (previous_lhs && UNIQSTR_EQ (previous_lhs->symbol->tag,
@@ -79,13 +75,13 @@ print_core (struct obstack *oout, state *s)
         obstack_printf (oout, "%s: ", escape (r->lhs->symbol->tag));
       previous_lhs = r->lhs;
 
-      for (sp = r->rhs; sp < sp1; sp++)
+      for (item_number const *sp = r->rhs; sp < sp1; sp++)
         obstack_printf (oout, "%s ", escape (symbols[*sp]->tag));
 
       obstack_1grow (oout, '.');
 
       if (0 <= *r->rhs)
-        for (/* Nothing */; *sp >= 0; ++sp)
+        for (item_number const *sp = sp1; 0 <= *sp; ++sp)
           obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
       else
         obstack_printf (oout, " %%empty");
diff --git a/src/print-xml.c b/src/print-xml.c
index e3c6ffde..c4dac106 100644
--- a/src/print-xml.c
+++ b/src/print-xml.c
@@ -77,14 +77,8 @@ print_core (FILE *out, int level, state *s)
     {
       bool printed = false;
       item_number *sp1 = ritem + sitems[i];
-      item_number *sp = sp1;
-      rule *r;
-
-      while (0 <= *sp)
-        sp++;
-
-      r = &rules[item_number_as_rule_number (*sp)];
-      sp = r->rhs;
+      rule const *r = item_rule (sp1);
+      item_number *sp = r->rhs;
 
       /* Display the lookahead tokens?  */
       if (item_number_is_rule_number (*sp1))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]