/[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.69 by akim, Sun Jun 30 17:27:34 2002 UTC revision 1.70 by akim, Sun Jun 30 17:28:44 2002 UTC
# Line 37  Line 37 
37  #include "lalr.h"  #include "lalr.h"
38  #include "reduce.h"  #include "reduce.h"
39    
 state_number_t nstates = 0;  
 /* FINAL_STATE is properly set by new_state when it recognizes its  
    accessing symbol: EOF.  */  
 state_t *final_state = NULL;  
40  static state_t *first_state = NULL;  static state_t *first_state = NULL;
41    
42  static state_t *this_state = NULL;  static state_t *this_state = NULL;
# Line 182  new_itemsets (void) Line 178  new_itemsets (void)
178  static state_t *  static state_t *
179  new_state (symbol_number_t symbol, size_t core_size, item_number_t *core)  new_state (symbol_number_t symbol, size_t core_size, item_number_t *core)
180  {  {
181    state_t *p;    state_t *res;
182    
183    if (trace_flag)    if (trace_flag)
184      fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",      fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
185               nstates, symbol, symbol_tag_get (symbols[symbol]));               nstates, symbol, symbol_tag_get (symbols[symbol]));
186    
187    if (nstates >= STATE_NUMBER_MAX)    res = state_new (symbol, core_size, core);
     fatal (_("too many states (max %d)"), STATE_NUMBER_MAX);  
   
   p = STATE_ALLOC (core_size);  
   p->accessing_symbol = symbol;  
   p->number = nstates;  
   p->solved_conflicts = NULL;  
   
   p->nitems = core_size;  
   memcpy (p->items, core, core_size * sizeof (core[0]));  
188    
189    /* If this is the eoftoken, and this is not the initial state, then    /* If this is the eoftoken, and this is not the initial state, then
190       this is the final state.  */       this is the final state.  */
191    if (symbol == 0 && first_state)    if (symbol == 0 && first_state)
192      final_state = p;      final_state = res;
193    
194    if (!first_state)    if (!first_state)
195      first_state = p;      first_state = res;
196    if (last_state)    if (last_state)
197      last_state->next = p;      last_state->next = res;
198    last_state = p;    last_state = res;
   
   nstates++;  
199    
200    return p;    return res;
201  }  }
202    
203    

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.70

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