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

Diff of /bison/src/LR0.c

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

revision 1.58 by akim, Sun Apr 7 17:38:37 2002 UTC revision 1.59 by akim, Sun Apr 7 17:40:16 2002 UTC
# Line 35  Line 35 
35  #include "lalr.h"  #include "lalr.h"
36  #include "reduce.h"  #include "reduce.h"
37    
38  unsigned int nstates;  unsigned int nstates = 0;
39  /* Initialize the final state to -1, otherwise, it might be set to 0  /* Initialize the final state to -1, otherwise, it might be set to 0
40     by default, and since we don't compute the reductions of the final     by default, and since we don't compute the reductions of the final
41     state, we end up not computing the reductions of the initial state,     state, we end up not computing the reductions of the initial state,
# Line 190  new_state (int symbol) Line 190  new_state (int symbol)
190    
191    if (trace_flag)    if (trace_flag)
192      fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",      fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
193               this_state->number, symbol, symbols[symbol]->tag);               nstates, symbol, symbols[symbol]->tag);
194    
195    if (nstates >= MAXSHORT)    if (nstates >= MAXSHORT)
196      fatal (_("too many states (max %d)"), MAXSHORT);      fatal (_("too many states (max %d)"), MAXSHORT);
# Line 202  new_state (int symbol) Line 202  new_state (int symbol)
202    
203    shortcpy (p->items, kernel_base[symbol], kernel_size[symbol]);    shortcpy (p->items, kernel_base[symbol], kernel_size[symbol]);
204    
205    last_state->next = p;    /* If this is the eoftoken, and this is not the initial state, then
206         this is the final state.  */
207      if (symbol == 0 && first_state)
208        final_state = p->number;
209    
210      if (!first_state)
211        first_state = p;
212      if (last_state)
213        last_state->next = p;
214    last_state = p;    last_state = p;
   nstates++;  
215    
216    /* If this is the eoftoken, then this is the final state. */    nstates++;
   if (symbol == 0)  
     final_state = p->number;  
217    
218    return p;    return p;
219  }  }
# Line 317  append_states (void) Line 322  append_states (void)
322  static void  static void
323  new_states (void)  new_states (void)
324  {  {
325    first_state = last_state = this_state = STATE_ALLOC (0);    /* The 0 at the lhs is the index of the item of this initial rule.  */
326    nstates = 1;    kernel_base[0][0] = 0;
327      kernel_size[0] = 1;
328      this_state = new_state (0);
329  }  }
330    
331    

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59

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