bison-patches
[Top][All Lists]
Advanced

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

35-fyi-itemsetsize.patch


From: Akim Demaille
Subject: 35-fyi-itemsetsize.patch
Date: Mon, 19 Nov 2001 10:04:33 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/closure.c (itemsetend): Remove, replaced with...
        (itemsetsize): new.
        
        
Index: src/LR0.c
--- src/LR0.c Sun, 18 Nov 2001 13:12:38 +0100 akim
+++ src/LR0.c Sun, 18 Nov 2001 13:20:58 +0100 akim
@@ -150,7 +150,7 @@
 
   shiftcount = 0;
 
-  for (i = 0; i < itemsetend - itemset; ++i)
+  for (i = 0; i < itemsetsize; ++i)
     {
       int symbol = ritem[itemset[i]];
       if (symbol > 0)
@@ -544,19 +544,15 @@
 static void
 save_reductions (void)
 {
-  short *isp;
-  int item;
   int count;
-  reductions *p;
-
-  short *rend;
+  int i;
 
   /* Find and count the active items that represent ends of rules. */
 
   count = 0;
-  for (isp = itemset; isp < itemsetend; isp++)
+  for (i = 0; i < itemsetsize; ++i)
     {
-      item = ritem[*isp];
+      int item = ritem[itemset[i]];
       if (item < 0)
        redset[count++] = -item;
     }
@@ -565,7 +561,7 @@
 
   if (count)
     {
-      p = REDUCTIONS_ALLOC (count);
+      reductions *p = REDUCTIONS_ALLOC (count);
 
       p->number = this_state->number;
       p->nreds = count;
Index: src/closure.c
--- src/closure.c Sun, 18 Nov 2001 12:36:37 +0100 akim
+++ src/closure.c Sun, 18 Nov 2001 13:23:55 +0100 akim
@@ -26,8 +26,10 @@
 #include "derives.h"
 #include "warshall.h"
 
+/* ITEMSETSIZE is the size of the array ITEMSET.  */
 short *itemset;
-short *itemsetend;
+size_t itemsetsize;
+
 static unsigned *ruleset;
 
 /* internal data.  See comments before set_fderives and set_firsts.  */
@@ -51,11 +53,10 @@
 static void
 print_closure (int n)
 {
-  short *isp;
-
+  int i;
   fprintf (stderr, "n = %d\n", n);
-  for (isp = itemset; isp < itemsetend; isp++)
-    fprintf (stderr, "   %d\n", *isp);
+  for (i = 0; i < itemsetsize; ++i)
+    fprintf (stderr, "   %d\n", itemset[i]);
   fprintf (stderr, "\n\n");
 }
 
@@ -265,9 +266,9 @@
     }
 
   ruleno = 0;
-  itemsetend = itemset;
+  itemsetsize = 0;
   csp = core;
-  for (i= 0; i < rulesetsize; ++i)
+  for (i = 0; i < rulesetsize; ++i)
     {
       int word = ruleset[i];
       if (word == 0)
@@ -283,9 +284,9 @@
              if (word & (1 << b))
                {
                  itemno = rule_table[ruleno].rhs;
-                 while (csp < (core + n ) && *csp < itemno)
-                   *itemsetend++ = *csp++;
-                 *itemsetend++ = itemno;
+                 while (csp < (core + n) && *csp < itemno)
+                   itemset[itemsetsize++] = *csp++;
+                 itemset[itemsetsize++] = itemno;
                }
 
              ruleno++;
@@ -294,7 +295,7 @@
     }
 
   while (csp < (core + n))
-    *itemsetend++ = *csp++;
+    itemset[itemsetsize++] = *csp++;
 
   if (trace_flag)
     print_closure (n);
Index: src/closure.h
--- src/closure.h Sat, 11 Nov 2000 16:04:34 +0100 akim
+++ src/closure.h Sun, 18 Nov 2001 13:21:19 +0100 akim
@@ -1,5 +1,5 @@
 /* Subroutines for bison
-   Copyright 1984, 1989, 2000 Free Software Foundation, Inc.
+   Copyright 1984, 1989, 2000, 2001  Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -51,6 +51,6 @@
 void free_closure PARAMS ((void));
 
 extern short *itemset;
-extern short *itemsetend;
+extern size_t itemsetsize;
 
 #endif /* !CLOSURE_H_ */



reply via email to

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