bison-patches
[Top][All Lists]
Advanced

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

12-fyi-attach-shifts-to-states.patch


From: Akim Demaille
Subject: 12-fyi-attach-shifts-to-states.patch
Date: Mon, 10 Dec 2001 09:36:14 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/LR0.c: Attach shifts to states as soon as they are
        computed.
        * src/lalr.c (set_state_table): Instead of assigning shifts to
        state, just assert that the mapping was properly done.
        
        
Index: src/LR0.c
--- src/LR0.c Sat, 08 Dec 2001 18:49:57 +0100 akim
+++ src/LR0.c Sat, 08 Dec 2001 19:04:52 +0100 akim
@@ -320,8 +320,8 @@
   shifts *p = shifts_new (nshifts);
 
   p->number = this_state->number;
-
   shortcpy (p->shifts, shiftset, nshifts);
+  this_state->shifts = p;
 
   if (last_shift)
     last_shift->next = p;
@@ -361,6 +361,7 @@
 
   /* Make a shift from this state to (what will be) the final state.  */
   sp = shifts_new (1);
+  statep->shifts = sp;
   sp->number = nstates++;
   sp->shifts[0] = nstates;
 
@@ -392,6 +393,7 @@
 
   /* Make the shift from the final state to the termination state.  */
   sp = shifts_new (1);
+  statep->shifts = sp;
   sp->number = nstates++;
   sp->shifts[0] = nstates;
 
@@ -441,6 +443,7 @@
         initial state to the next-to-final state.  */
 
       shifts *sp = shifts_new (1);
+      first_state->shifts = sp;
       sp->shifts[0] = nstates;
 
       /* Initialize the chain of shifts with sp.  */
@@ -477,6 +480,7 @@
              int i;
              shifts *sp2 = shifts_new (sp->nshifts + 1);
              sp2->number = statep->number;
+             statep->shifts = sp2;
              sp2->shifts[0] = nstates;
              for (i = sp->nshifts; i > 0; i--)
                sp2->shifts[i] = sp->shifts[i - 1];
@@ -493,6 +497,7 @@
            {
              shifts *sp2 = shifts_new (1);
              sp2->number = statep->number;
+             statep->shifts = sp2;
              sp2->shifts[0] = nstates;
 
              /* Patch sp2 into the chain of shifts between sp1 and sp.  */
@@ -512,7 +517,7 @@
          /* Add one more shift in first_shift,
             going to the next-to-final state (yet to be made).  */
          sp2 = shifts_new (sp->nshifts + 1);
-
+         first_state->shifts = sp2;
          /* Stick this shift into the vector at the proper place.  */
          statep = first_state->next;
          for (k = 0, i = 0; i < sp->nshifts; k++, i++)
@@ -544,6 +549,7 @@
       /* The initial state didn't even have any shifts.
         Give it one shift, to the next-to-final state.  */
       shifts *sp = shifts_new (1);
+      first_state->shifts = sp;
       sp->shifts[0] = nstates;
 
       /* Patch sp into the chain of shifts at the beginning.  */
Index: src/lalr.c
--- src/lalr.c Sat, 08 Dec 2001 15:51:17 +0100 akim
+++ src/lalr.c Sat, 08 Dec 2001 18:58:08 +0100 akim
@@ -153,7 +153,7 @@
   {
     shifts *sp;
     for (sp = first_shift; sp; sp = sp->next)
-      state_table[sp->number]->shifts = sp;
+      assert (state_table[sp->number]->shifts == sp);
   }
 
   /* Pessimization, but simplification of the code: make sure all the



reply via email to

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