/[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.46 by akim, Thu Dec 27 18:05:30 2001 UTC revision 1.47 by akim, Thu Dec 27 18:07:05 2001 UTC
# Line 159  initialize_LA (void) Line 159  initialize_LA (void)
159  static void  static void
160  set_goto_map (void)  set_goto_map (void)
161  {  {
162    int state;    int state, i;
   int i;  
   int symbol;  
   int k;  
163    short *temp_map;    short *temp_map;
   int state2;  
164    
165    goto_map = XCALLOC (short, nvars + 1) - ntokens;    goto_map = XCALLOC (short, nvars + 1) - ntokens;
166    temp_map = XCALLOC (short, nvars + 1) - ntokens;    temp_map = XCALLOC (short, nvars + 1) - ntokens;
# Line 175  set_goto_map (void) Line 171  set_goto_map (void)
171        shifts *sp = state_table[state]->shifts;        shifts *sp = state_table[state]->shifts;
172        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
173          {          {
174            symbol = state_table[sp->shifts[i]]->accessing_symbol;            int symbol = state_table[sp->shifts[i]]->accessing_symbol;
175    
176            if (ngotos == MAXSHORT)            if (ngotos == MAXSHORT)
177              fatal (_("too many gotos (max %d)"), MAXSHORT);              fatal (_("too many gotos (max %d)"), MAXSHORT);
# Line 185  set_goto_map (void) Line 181  set_goto_map (void)
181          }          }
182      }      }
183    
184    k = 0;    {
185    for (i = ntokens; i < nsyms; i++)      int k = 0;
186      {      for (i = ntokens; i < nsyms; i++)
187        temp_map[i] = k;        {
188        k += goto_map[i];          temp_map[i] = k;
189      }          k += goto_map[i];
190          }
191    for (i = ntokens; i < nsyms; i++)  
192      goto_map[i] = temp_map[i];      for (i = ntokens; i < nsyms; i++)
193          goto_map[i] = temp_map[i];
194    goto_map[nsyms] = ngotos;  
195    temp_map[nsyms] = ngotos;      goto_map[nsyms] = ngotos;
196        temp_map[nsyms] = ngotos;
197      }
198    
199    from_state = XCALLOC (short, ngotos);    from_state = XCALLOC (short, ngotos);
200    to_state = XCALLOC (short, ngotos);    to_state = XCALLOC (short, ngotos);
# Line 206  set_goto_map (void) Line 204  set_goto_map (void)
204        shifts *sp = state_table[state]->shifts;        shifts *sp = state_table[state]->shifts;
205        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)        for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
206          {          {
207            for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)            int state2 = sp->shifts[i];
208              {            int symbol = state_table[state2]->accessing_symbol;
209                state2 = sp->shifts[i];  
210                symbol = state_table[state2]->accessing_symbol;            int k = temp_map[symbol]++;
211              from_state[k] = state;
212                k = temp_map[symbol]++;            to_state[k] = state2;
               from_state[k] = state;  
               to_state[k] = state2;  
             }  
213          }          }
214      }      }
215    

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

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