bison-patches
[Top][All Lists]
Advanced

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

20-fyi-initialize-lookahead.patch


From: Akim Demaille
Subject: 20-fyi-initialize-lookahead.patch
Date: Mon, 10 Dec 2001 09:36:55 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * src/lalr.c (initialize_lookaheads): New.  Extracted from...
        * src/LR0.c (set_state_table): here.
        * src/lalr.c (lalr): Call it.
        
Index: src/LR0.c
--- src/LR0.c Sat, 08 Dec 2001 22:32:43 +0100 akim
+++ src/LR0.c Sun, 09 Dec 2001 11:42:41 +0100 akim
@@ -560,39 +560,6 @@
       if (!state_table[i]->shifts)
        state_table[i]->shifts = shifts_new (0);
   }
-
-  /* Initializing the lookaheads members.  Please note that it must be
-     performed after having set some of the other members which are
-     used below.  Change with extreme caution.  */
-  {
-    int i;
-    int count = 0;
-    for (i = 0; i < nstates; i++)
-      {
-       int k;
-       reductions *rp = state_table[i]->reductions;
-       shifts *sp = state_table[i]->shifts;
-
-       state_table[i]->lookaheads = count;
-
-       if (rp
-           && (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
-         count += rp->nreds;
-       else
-         state_table[i]->consistent = 1;
-
-       for (k = 0; k < sp->nshifts; k++)
-         if (SHIFT_IS_ERROR (sp, k))
-           {
-             state_table[i]->consistent = 0;
-             break;
-           }
-      }
-
-    /* Seems to be needed by conflicts.c. */
-    state_table[nstates] = STATE_ALLOC (0);
-    state_table[nstates]->lookaheads = count;
-  }
 }
 
 /*-------------------------------------------------------------------.
Index: src/lalr.c
--- src/lalr.c Sat, 08 Dec 2001 20:47:14 +0100 akim
+++ src/lalr.c Sun, 09 Dec 2001 11:44:43 +0100 akim
@@ -534,11 +534,48 @@
 }
 
 
+/*--------------------------------------.
+| Initializing the lookaheads members.  |
+`--------------------------------------*/
+
+static void
+initialize_lookaheads (void)
+{
+  int i;
+  int count = 0;
+  for (i = 0; i < nstates; i++)
+    {
+      int k;
+      reductions *rp = state_table[i]->reductions;
+      shifts *sp = state_table[i]->shifts;
+
+      state_table[i]->lookaheads = count;
+
+      if (rp
+         && (rp->nreds > 1 || (sp->nshifts && SHIFT_IS_SHIFT (sp, 0))))
+       count += rp->nreds;
+      else
+       state_table[i]->consistent = 1;
+
+      for (k = 0; k < sp->nshifts; k++)
+       if (SHIFT_IS_ERROR (sp, k))
+         {
+           state_table[i]->consistent = 0;
+           break;
+         }
+    }
+
+  /* Seems to be needed by conflicts.c. */
+  state_table[nstates] = STATE_ALLOC (0);
+  state_table[nstates]->lookaheads = count;
+}
+
 void
 lalr (void)
 {
   tokensetsize = WORDSIZE (ntokens);
 
+  initialize_lookaheads ();
   initialize_LA ();
   set_goto_map ();
   initialize_F ();



reply via email to

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