/[bison]/bison/src/lalr.c
ViewVC logotype

Diff of /bison/src/lalr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16.2.5 by akim, Mon Nov 19 09:10:47 2001 UTC revision 1.16.2.6 by akim, Mon Nov 19 09:11:03 2001 UTC
# Line 169  set_state_table (void) Line 169  set_state_table (void)
169      for (rp = first_reduction; rp; rp = rp->next)      for (rp = first_reduction; rp; rp = rp->next)
170        state_table[rp->number].reduction_table = rp;        state_table[rp->number].reduction_table = rp;
171    }    }
172    
173      /* Initializing the lookaheads members.  Please note that it must be
174         performed after having set some of the other members which are
175         used below.  Change with extreme caution.  */
176      {
177        int i;
178        int count = 0;
179        for (i = 0; i < nstates; i++)
180          {
181            int k;
182            reductions *rp = state_table[i].reduction_table;
183            shifts *sp = state_table[i].shift_table;
184    
185            state_table[i].lookaheads = count;
186    
187            if (rp
188                && (rp->nreds > 1
189                    || (sp && !ISVAR (state_table[sp->shifts[0]].accessing_symbol))))
190              count += rp->nreds;
191            else
192              state_table[i].consistent = 1;
193    
194            if (sp)
195              for (k = 0; k < sp->nshifts; k++)
196                if (state_table[sp->shifts[k]].accessing_symbol
197                    == error_token_number)
198                  {
199                    state_table[i].consistent = 0;
200                    break;
201                  }
202          }
203         state_table[nstates].lookaheads = count;
204      }
205  }  }
206    
207    
# Line 204  initialize_LA (void) Line 237  initialize_LA (void)
237  {  {
238    int i;    int i;
239    int j;    int j;
   int count = 0;  
   reductions *rp;  
   shifts *sp;  
240    short *np;    short *np;
241      reductions *rp;
242    
243    for (i = 0; i < nstates; i++)    size_t nLA = state_table[nstates].lookaheads;
244      {    if (!nLA)
245        int k;      nLA = 1;
246    
247        state_table[i].lookaheads = count;    LA = XCALLOC (unsigned, nLA * tokensetsize);
248      LAruleno = XCALLOC (short, nLA);
249        rp = state_table[i].reduction_table;    lookback = XCALLOC (shorts *, nLA);
       sp = state_table[i].shift_table;  
       if (rp  
           && (rp->nreds > 1  
               || (sp && !ISVAR (state_table[sp->shifts[0]].accessing_symbol))))  
         count += rp->nreds;  
       else  
         state_table[i].consistent = 1;  
   
       if (sp)  
         for (k = 0; k < sp->nshifts; k++)  
           if (state_table[sp->shifts[k]].accessing_symbol  
               == error_token_number)  
             {  
               state_table[i].consistent = 0;  
               break;  
             }  
     }  
   
   state_table[nstates].lookaheads = count;  
   
   if (count == 0)  
     {  
       LA = XCALLOC (unsigned, 1 * tokensetsize);  
       LAruleno = XCALLOC (short, 1);  
       lookback = XCALLOC (shorts *, 1);  
     }  
   else  
     {  
       LA = XCALLOC (unsigned, count * tokensetsize);  
       LAruleno = XCALLOC (short, count);  
       lookback = XCALLOC (shorts *, count);  
     }  
250    
251    np = LAruleno;    np = LAruleno;
252    for (i = 0; i < nstates; i++)    for (i = 0; i < nstates; i++)
253      {      if (!state_table[i].consistent)
254        if (!state_table[i].consistent)        if ((rp = state_table[i].reduction_table))
255          {          for (j = 0; j < rp->nreds; j++)
256            if ((rp = state_table[i].reduction_table))            *np++ = rp->rules[j];
             for (j = 0; j < rp->nreds; j++)  
               *np++ = rp->rules[j];  
         }  
     }  
257  }  }
258    
259    

Legend:
Removed from v.1.16.2.5  
changed lines
  Added in v.1.16.2.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26