]> git.saurik.com Git - bison.git/commitdiff
* src/state.h, src/state.c (shifts_to): New.
authorAkim Demaille <akim@epita.fr>
Sun, 30 Jun 2002 17:31:37 +0000 (17:31 +0000)
committerAkim Demaille <akim@epita.fr>
Sun, 30 Jun 2002 17:31:37 +0000 (17:31 +0000)
* src/lalr.c (build_relations): Use it.

ChangeLog
src/lalr.c
src/state.c
src/state.h

index ed8ec2ed2e10ef55244ec4b7e1d0702def74ea4e..32efdc1be1d00c81860115d57c00bc900fe34395 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-06-30  Akim Demaille  <akim@epita.fr>
+
+       * src/state.h, src/state.c (shifts_to): New.
+       * src/lalr.c (build_relations): Use it.
+
+       
 2002-06-30  Akim Demaille  <akim@epita.fr>
 
        * src/gram.h (rule_number_t, RULE_NUMBER_MAX, int_of_rule_number)
index b1f84607ffb7396dd6e6d3f19d6cc450ab8f307b..c3a55cc452dd25d65c164298e01bc349aa8aa14b 100644 (file)
@@ -420,16 +420,8 @@ build_relations (void)
 
          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 dd8ec7500c5387e82313f81c8aad0e028c17cc88..f365039d76da65a424331d27c28d7fe2827c8fca 100644 (file)
@@ -49,6 +49,20 @@ shifts_new (int nshifts, state_number_t *shifts)
 }
 
 
+/*-----------------------------------------------------------------.
+| 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 074b1eea47bdfd0e63b0f86316c77632c79310ec..674e1714acf698699fa6bbc725ca63e9d7e85857 100644 (file)
@@ -139,6 +139,10 @@ typedef struct shifts_s
 #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.  |