bison-patches
[Top][All Lists]
Advanced

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

02-fyi-use-nritems.patch


From: Akim Demaille
Subject: 02-fyi-use-nritems.patch
Date: Sat, 29 Dec 2001 15:13:22 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/LR0.c (generate_states): Use nritems, not nitems, nor using
        the 0-sentinel.
        * src/gram.c (ritem_longest_rhs): Likewise.
        * src/reduce.c (nonterminals_reduce): Likewise.
        * src/print_graph.c (print_graph): Likewise.
        * src/output.c (output_rule_data): Likewise.
        * src/nullable.c (set_nullable):  Likewise.

Index: src/LR0.c
--- src/LR0.c Thu, 27 Dec 2001 17:14:11 +0100 akim
+++ src/LR0.c Fri, 28 Dec 2001 14:41:29 +0100 akim
@@ -391,7 +391,7 @@
 generate_states (void)
 {
   allocate_storage ();
-  new_closure (nitems);
+  new_closure (nritems);
   new_states ();

   while (this_state)
Index: src/gram.c
--- src/gram.c Thu, 27 Dec 2001 15:45:59 +0100 akim
+++ src/gram.c Fri, 28 Dec 2001 14:41:29 +0100 akim
@@ -78,14 +78,14 @@
 size_t
 ritem_longest_rhs (void)
 {
-  short *itemp;
   int length;
   int max;
+  int i;

   length = 0;
   max = 0;
-  for (itemp = ritem; *itemp; itemp++)
-    if (*itemp > 0)
+  for (i = 0; i < nritems; ++i)
+    if (ritem[i] >= 0)
       {
        length++;
       }
Index: src/output.c
--- src/output.c Fri, 28 Dec 2001 12:22:48 +0100 akim
+++ src/output.c Fri, 28 Dec 2001 14:41:29 +0100 akim
@@ -294,7 +294,7 @@
   short_tab = XMALLOC (short, nrules + 1);
   for (i = 1; i < nrules; i++)
     short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1;
-  short_tab[nrules] =  nitems - rule_table[nrules].rhs - 1;
+  short_tab[nrules] =  nritems - rule_table[nrules].rhs - 1;
   output_table_data (&format_obstack, short_tab,
                     0, 1, nrules + 1);
   muscle_insert ("r2", obstack_finish (&format_obstack));
Index: src/print.c
--- src/print.c Fri, 28 Dec 2001 12:06:07 +0100 akim
+++ src/print.c Fri, 28 Dec 2001 14:41:29 +0100 akim
@@ -495,7 +495,7 @@
      only its kernel.  Requires to run closure, which need memory
      allocation/deallocation.  */
   if (trace_flag)
-    new_closure (nitems);
+    new_closure (nritems);
   /* Storage for print_reductions.  */
   shiftset = XCALLOC (unsigned, tokensetsize);
   lookaheadset = XCALLOC (unsigned, tokensetsize);
Index: src/print_graph.c
--- src/print_graph.c Fri, 28 Dec 2001 12:06:07 +0100 akim
+++ src/print_graph.c Fri, 28 Dec 2001 14:41:29 +0100 akim
@@ -199,7 +199,7 @@
   output_graph (&graph, fgraph);

   /* Output nodes and edges. */
-  new_closure (nitems);
+  new_closure (nritems);
   for (i = 0; i < nstates; i++)
     print_state (state_table[i]);
   free_closure ();
Index: src/reduce.c
--- src/reduce.c Thu, 27 Dec 2001 17:14:11 +0100 akim
+++ src/reduce.c Fri, 28 Dec 2001 14:41:29 +0100 akim
@@ -383,9 +383,9 @@
        rule_table[i].precsym = nontermmap[rule_table[i].precsym];
     }

-  for (r = ritem; *r; r++)
-    if (ISVAR (*r))
-      *r = nontermmap[*r];
+  for (i = 0; i < nritems; ++i)
+    if (ISVAR (ritem[i]))
+      ritem[i] = nontermmap[ritem[i]];

   start_symbol = nontermmap[start_symbol];

Index: src/nullable.c
--- src/nullable.c Fri, 28 Dec 2001 14:55:09 +0100 akim
+++ src/nullable.c Fri, 28 Dec 2001 15:00:23 +0100 akim
@@ -57,8 +57,8 @@
      Hence we must allocate room for useless nonterminals too.  */
   shorts **rsets = XCALLOC (shorts *, nvars) - ntokens;
   /* This is said to be more elements than we actually use.
-     Supposedly nitems - nrules is enough.  But why take the risk?  */
-  shorts *relts = XCALLOC (shorts, nitems + nvars + 1);
+     Supposedly NRITEMS - NRULES is enough.  But why take the risk?  */
+  shorts *relts = XCALLOC (shorts, nritems + nvars + 1);

   if (trace_flag)
     fprintf (stderr, "Entering set_nullable\n");



reply via email to

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