]> git.saurik.com Git - bison.git/commitdiff
* src/state.h (state_t): Rename lookaheads as lookaheadsp.
authorAkim Demaille <akim@epita.fr>
Mon, 17 Dec 2001 17:32:59 +0000 (17:32 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 17 Dec 2001 17:32:59 +0000 (17:32 +0000)
nlookaheads is a new member.
Adjust all users.
* src/lalr.h (nlookaheads): Remove this orphan declaration.
* src/lalr.c (initialize_lookaheads): Set nlookaheads for each
state.

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

index 98b415f7d649fb005889e811a35b5b3cf1742ffd..62a37342457d36a0b06c3a704988adb2a272b399 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-12-17  Akim Demaille  <akim@epita.fr>
+
+       * src/state.h (state_t): Rename lookaheads as lookaheadsp.
+       nlookaheads is a new member.
+       Adjust all users.
+       * src/lalr.h (nlookaheads): Remove this orphan declaration.
+       * src/lalr.c (initialize_lookaheads): Set nlookaheads for each
+       state.
+
+       
 2001-12-17  Akim Demaille  <akim@epita.fr>
 
        * src/files.h, src/files.c (open_files, close_files): Remove.
index f10c36b335d6dcbed3b370dfb4f2cd613f7696fa..3954cc319900b1fded9ed32f94b5d8016067d73d 100644 (file)
@@ -172,8 +172,8 @@ set_conflicts (int state)
   /* Loop over all rules which require lookahead in this state.  First
      check for shift-reduce conflict, and try to resolve using
      precedence */
-  for (i = state_table[state]->lookaheads;
-       i < state_table[state + 1]->lookaheads;
+  for (i = state_table[state]->lookaheadsp;
+       i < state_table[state + 1]->lookaheadsp;
        ++i)
     if (rule_table[LAruleno[i]].prec)
       for (j = 0; j < tokensetsize; ++j)
@@ -186,8 +186,8 @@ set_conflicts (int state)
 
   /* Loop over all rules which require lookahead in this state.  Check
      for conflicts not resolved above.  */
-  for (i = state_table[state]->lookaheads;
-       i < state_table[state + 1]->lookaheads;
+  for (i = state_table[state]->lookaheadsp;
+       i < state_table[state + 1]->lookaheadsp;
        ++i)
     {
       for (j = 0; j < tokensetsize; ++j)
@@ -237,8 +237,8 @@ count_sr_conflicts (int state)
     if (!SHIFT_IS_DISABLED (shiftp, i))
       SETBIT (shiftset, SHIFT_SYMBOL (shiftp, i));
 
-  for (i = state_table[state]->lookaheads;
-       i < state_table[state + 1]->lookaheads;
+  for (i = state_table[state]->lookaheadsp;
+       i < state_table[state + 1]->lookaheadsp;
        ++i)
     for (k = 0; k < tokensetsize; ++k)
       lookaheadset[k] |= LA (i)[k];
@@ -264,8 +264,8 @@ count_rr_conflicts (int state)
   int i;
   int rrc_count = 0;
 
-  int m = state_table[state]->lookaheads;
-  int n = state_table[state + 1]->lookaheads;
+  int m = state_table[state]->lookaheadsp;
+  int n = state_table[state + 1]->lookaheadsp;
 
   if (n - m < 2)
     return 0;
@@ -414,8 +414,8 @@ print_reductions (FILE *out, int state)
 {
   int i;
   int j;
-  int m = state_table[state]->lookaheads;
-  int n = state_table[state + 1]->lookaheads;
+  int m = state_table[state]->lookaheadsp;
+  int n = state_table[state + 1]->lookaheadsp;
   shifts *shiftp = state_table[state]->shifts;
   errs *errp = state_table[state]->errs;
   int nodefault = 0;
index 150b15e9df0e46301bd0fcad742cde52e3c5b950..a4150cb7735704c582b3095123cb7014c9678e9b 100644 (file)
@@ -140,7 +140,7 @@ initialize_LA (void)
   short *np;
   reductions *rp;
 
-  size_t nLA = state_table[nstates]->lookaheads;
+  size_t nLA = state_table[nstates]->lookaheadsp;
   if (!nLA)
     nLA = 1;
 
@@ -314,8 +314,8 @@ add_lookback_edge (int stateno, int ruleno, int gotono)
   int found;
   shorts *sp;
 
-  i = state_table[stateno]->lookaheads;
-  k = state_table[stateno + 1]->lookaheads;
+  i = state_table[stateno]->lookaheadsp;
+  k = state_table[stateno + 1]->lookaheadsp;
   found = 0;
   while (!found && i < k)
     {
@@ -516,7 +516,7 @@ compute_lookaheads (void)
   int i;
   shorts *sp;
 
-  for (i = 0; i < state_table[nstates]->lookaheads; i++)
+  for (i = 0; i < state_table[nstates]->lookaheadsp; i++)
     for (sp = lookback[i]; sp; sp = sp->next)
       {
        int size = LA (i + 1) - LA (i);
@@ -526,7 +526,7 @@ compute_lookaheads (void)
       }
 
   /* Free LOOKBACK. */
-  for (i = 0; i < state_table[nstates]->lookaheads; i++)
+  for (i = 0; i < state_table[nstates]->lookaheadsp; i++)
     LIST_FREE (shorts, lookback[i]);
 
   XFREE (lookback);
@@ -546,14 +546,13 @@ initialize_lookaheads (void)
   for (i = 0; i < nstates; i++)
     {
       int k;
+      int nlookaheads = 0;
       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;
+       nlookaheads += rp->nreds;
       else
        state_table[i]->consistent = 1;
 
@@ -563,11 +562,15 @@ initialize_lookaheads (void)
            state_table[i]->consistent = 0;
            break;
          }
+
+      state_table[i]->nlookaheads = nlookaheads;
+      state_table[i]->lookaheadsp = count;
+      count += nlookaheads;
     }
 
   /* Seems to be needed by conflicts.c. */
   state_table[nstates] = STATE_ALLOC (0);
-  state_table[nstates]->lookaheads = count;
+  state_table[nstates]->lookaheadsp = count;
 }
 
 void
index fd964b7b0bbb1a5d96c09a303930c963c2627763..31cf806983a072b90d78f5f0abd07a67fab371b1 100644 (file)
@@ -74,6 +74,4 @@ extern state_t **state_table;
 
 extern int tokensetsize;
 
-/* The number of lookaheads. */
-extern size_t nlookaheads;
 #endif /* !LALR_H_ */
index c35fa8701c7f2125990cb4e84fbdbf2198b3b783..125070eab7f2f61984463563376efe72ff2b32ec 100644 (file)
@@ -344,8 +344,8 @@ action_row (int state)
       int j;
       /* loop over all the rules available here which require
         lookahead */
-      m = state_table[state]->lookaheads;
-      n = state_table[state + 1]->lookaheads;
+      m = state_table[state]->lookaheadsp;
+      n = state_table[state + 1]->lookaheadsp;
 
       for (i = n - 1; i >= m; i--)
        /* and find each token which the rule finds acceptable
index de7ec08ccbe4f464efdbd84c20ffe86b3413939f..a31af20bcd675750678bca2a7fe6dd4bb1323771 100644 (file)
@@ -189,7 +189,9 @@ typedef struct state_s
   char consistent;
 
   /* Used in LALR, not LR(0). */
-  short lookaheads;
+  /* Pseudo pointer into LA. */
+  short lookaheadsp;
+  int nlookaheads;
 
   /* Its items. */
   short nitems;