bison-patches
[Top][All Lists]
Advanced

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

11-shifts-to.patch


From: Akim Demaille
Subject: 11-shifts-to.patch
Date: Sun, 30 Jun 2002 19:27:18 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/state.h, src/state.c (shifts_to): New.
        * src/lalr.c (build_relations): Use it.
        
        
Index: src/lalr.c
--- src/lalr.c Sat, 29 Jun 2002 15:49:57 +0200 akim
+++ src/lalr.c Sat, 29 Jun 2002 16:18:02 +0200 akim
@@ -420,16 +420,8 @@
 
          for (rp = rules[*rulep].rhs; *rp >= 0; rp++)
            {
-             shifts_t *sp = state->shifts;
-             int j;
-             for (j = 0; j < sp->nshifts; j++)
-               {
-                 state = states[sp->shifts[j]];
-                 if (state->accessing_symbol
-                     == item_number_as_symbol_number (*rp))
-                   break;
-               }
-
+             state = shifts_to (state->shifts,
+                                item_number_as_symbol_number (*rp));
              states1[length++] = state->number;
            }
 
Index: src/state.c
--- src/state.c Sat, 29 Jun 2002 14:02:21 +0200 akim
+++ src/state.c Sat, 29 Jun 2002 16:11:32 +0200 akim
@@ -49,6 +49,20 @@
 }
 
 
+/*-----------------------------------------------------------------.
+| Return the state such these SHIFTS contain a shift/goto to it on |
+| SYMBOL.  Aborts if none found.                                   |
+`-----------------------------------------------------------------*/
+
+state_t *
+shifts_to (shifts_t *shifts, symbol_number_t s)
+{
+  int j;
+  for (j = 0; j < shifts->nshifts; j++)
+    if (SHIFT_SYMBOL (shifts, j) == s)
+      return states[shifts->shifts[j]];
+  abort ();
+}
 
 
                        /*--------------------.
Index: src/state.h
--- src/state.h Sat, 29 Jun 2002 14:02:21 +0200 akim
+++ src/state.h Sat, 29 Jun 2002 16:19:13 +0200 akim
@@ -139,6 +139,10 @@
 #define SHIFT_IS_DISABLED(Shifts, Shift) \
   (Shifts->shifts[Shift] == 0)
 
+/* Return the state such these SHIFTS contain a shift/goto to it on
+   SYMBOL.  Aborts if none found.  */
+struct state_s;
+struct state_s *shifts_to PARAMS ((shifts_t *shifts, symbol_number_t s));
 
 /*-------.
 | Errs.  |



reply via email to

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