/[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.45 by akim, Thu Dec 27 18:05:05 2001 UTC revision 1.46 by akim, Thu Dec 27 18:05:30 2001 UTC
# Line 33  Line 33 
33  #include "derives.h"  #include "derives.h"
34  #include "getargs.h"  #include "getargs.h"
35    
36  /* All the decorated states, indexed by the state number.  Warning:  /* All the decorated states, indexed by the state number.  */
    there is a state_TABLE in LR0.c, but it is different and static.  
    */  
37  state_t **state_table = NULL;  state_t **state_table = NULL;
38    
39  int tokensetsize;  int tokensetsize;
40  short *LAruleno;  short *LAruleno;
41  unsigned *LA;  unsigned *LA;
42    size_t nLA;
43    
44  static int ngotos;  static int ngotos;
45  short *goto_map;  short *goto_map;
# Line 140  initialize_LA (void) Line 139  initialize_LA (void)
139    short *np;    short *np;
140    reductions *rp;    reductions *rp;
141    
142    size_t nLA = state_table[nstates]->lookaheadsp;    /* Avoid having to special case 0.  */
143    if (!nLA)    if (!nLA)
144      nLA = 1;      nLA = 1;
145    
# Line 504  compute_FOLLOWS (void) Line 503  compute_FOLLOWS (void)
503  static void  static void
504  compute_lookaheads (void)  compute_lookaheads (void)
505  {  {
506    int i;    size_t i;
507    shorts *sp;    shorts *sp;
508    
509    for (i = 0; i < state_table[nstates]->lookaheadsp; i++)    for (i = 0; i < nLA; i++)
510      for (sp = lookback[i]; sp; sp = sp->next)      for (sp = lookback[i]; sp; sp = sp->next)
511        {        {
512          int size = LA (i + 1) - LA (i);          int size = LA (i + 1) - LA (i);
# Line 517  compute_lookaheads (void) Line 516  compute_lookaheads (void)
516        }        }
517    
518    /* Free LOOKBACK. */    /* Free LOOKBACK. */
519    for (i = 0; i < state_table[nstates]->lookaheadsp; i++)    for (i = 0; i < nLA; i++)
520      LIST_FREE (shorts, lookback[i]);      LIST_FREE (shorts, lookback[i]);
521    
522    XFREE (lookback);    XFREE (lookback);
# Line 533  static void Line 532  static void
532  initialize_lookaheads (void)  initialize_lookaheads (void)
533  {  {
534    int i;    int i;
535    int count = 0;    nLA = 0;
536    for (i = 0; i < nstates; i++)    for (i = 0; i < nstates; i++)
537      {      {
538        int k;        int k;
# Line 555  initialize_lookaheads (void) Line 554  initialize_lookaheads (void)
554            }            }
555    
556        state_table[i]->nlookaheads = nlookaheads;        state_table[i]->nlookaheads = nlookaheads;
557        state_table[i]->lookaheadsp = count;        state_table[i]->lookaheadsp = nLA;
558        count += nlookaheads;        nLA += nlookaheads;
559      }      }
   
   /* Seems to be needed by conflicts.c. */  
   state_table[nstates] = STATE_ALLOC (0);  
   state_table[nstates]->lookaheadsp = count;  
560  }  }
561    
562  void  void

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.46

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