/[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.20 by akim, Mon Nov 19 10:08:02 2001 UTC revision 1.21 by akim, Mon Nov 19 10:08:20 2001 UTC
# Line 38  Line 38 
38  state_t *state_table = NULL;  state_t *state_table = NULL;
39    
40  int tokensetsize;  int tokensetsize;
 short *lookaheads;  
41  short *LAruleno;  short *LAruleno;
42  unsigned *LA;  unsigned *LA;
43    
# Line 145  digraph (short **relation) Line 144  digraph (short **relation)
144  static void  static void
145  set_state_table (void)  set_state_table (void)
146  {  {
147    state_table = XCALLOC (state_t, nstates);    /* NSTATES + 1 because lookahead for the pseudo state number NSTATES
148         might be used (see conflicts.c).  It is too opaque for me to
149         provide a probably less hacky implementation. --akim */
150      state_table = XCALLOC (state_t, nstates + 1);
151    
152    {    {
153      core *sp;      core *sp;
# Line 202  initialize_LA (void) Line 204  initialize_LA (void)
204  {  {
205    int i;    int i;
206    int j;    int j;
207    int count;    int count = 0;
208    reductions *rp;    reductions *rp;
209    shifts *sp;    shifts *sp;
210    short *np;    short *np;
211    
   lookaheads = XCALLOC (short, nstates + 1);  
   
   count = 0;  
212    for (i = 0; i < nstates; i++)    for (i = 0; i < nstates; i++)
213      {      {
214        int k;        int k;
215    
216        lookaheads[i] = count;        state_table[i].lookaheads = count;
217    
218        rp = state_table[i].reduction_table;        rp = state_table[i].reduction_table;
219        sp = state_table[i].shift_table;        sp = state_table[i].shift_table;
# Line 235  initialize_LA (void) Line 234  initialize_LA (void)
234              }              }
235      }      }
236    
237    lookaheads[nstates] = count;    state_table[nstates].lookaheads = count;
238    
239    if (count == 0)    if (count == 0)
240      {      {
# Line 450  add_lookback_edge (int stateno, int rule Line 449  add_lookback_edge (int stateno, int rule
449    int found;    int found;
450    shorts *sp;    shorts *sp;
451    
452    i = lookaheads[stateno];    i = state_table[stateno].lookaheads;
453    k = lookaheads[stateno + 1];    k = state_table[stateno + 1].lookaheads;
454    found = 0;    found = 0;
455    while (!found && i < k)    while (!found && i < k)
456      {      {
# Line 653  compute_lookaheads (void) Line 652  compute_lookaheads (void)
652    shorts *sptmp;                /* JF */    shorts *sptmp;                /* JF */
653    
654    rowp = LA;    rowp = LA;
655    n = lookaheads[nstates];    for (i = 0; i < state_table[nstates].lookaheads; i++)
   for (i = 0; i < n; i++)  
656      {      {
657        fp3 = rowp + tokensetsize;        fp3 = rowp + tokensetsize;
658        for (sp = lookback[i]; sp; sp = sp->next)        for (sp = lookback[i]; sp; sp = sp->next)
# Line 668  compute_lookaheads (void) Line 666  compute_lookaheads (void)
666        rowp = fp3;        rowp = fp3;
667      }      }
668    
669    for (i = 0; i < n; i++)    for (i = 0; i < state_table[nstates].lookaheads; i++)
670      {      {
671        /* JF removed ref to freed storage */        /* JF removed ref to freed storage */
672        for (sp = lookback[i]; sp; sp = sptmp)        for (sp = lookback[i]; sp; sp = sptmp)

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

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