/[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.15.2.8 by akim, Mon Nov 19 09:21:26 2001 UTC revision 1.15.2.9 by akim, Mon Nov 19 09:25:36 2001 UTC
# Line 24  Line 24 
24    
25  #include "system.h"  #include "system.h"
26  #include "getargs.h"  #include "getargs.h"
27    #include "reader.h"
28  #include "gram.h"  #include "gram.h"
29  #include "state.h"  #include "state.h"
30  #include "complain.h"  #include "complain.h"
# Line 61  static core **state_table = NULL; Line 62  static core **state_table = NULL;
62  static void  static void
63  allocate_itemsets (void)  allocate_itemsets (void)
64  {  {
   short *itemp = NULL;  
   int symbol;  
65    int i;    int i;
66    int count;    int count;
67    short *symbol_count = NULL;    short *symbol_count = NULL;
# Line 70  allocate_itemsets (void) Line 69  allocate_itemsets (void)
69    count = 0;    count = 0;
70    symbol_count = XCALLOC (short, nsyms);    symbol_count = XCALLOC (short, nsyms);
71    
72    itemp = ritem;    for (i = 0; ritem[i]; ++i)
73    symbol = *itemp++;      if (ritem[i] > 0)
74    while (symbol)        {
75      {          count++;
76        if (symbol > 0)          symbol_count[ritem[i]]++;
77          {        }
           count++;  
           symbol_count[symbol]++;  
         }  
       symbol = *itemp++;  
     }  
78    
79    /* See comments before new_itemsets.  All the vectors of items    /* See comments before new_itemsets.  All the vectors of items
80       live inside KERNEL_ITEMS.  The number of active items after       live inside KERNEL_ITEMS.  The number of active items after
# Line 149  new_itemsets (void) Line 143  new_itemsets (void)
143    int shiftcount;    int shiftcount;
144    
145    if (trace_flag)    if (trace_flag)
146      fprintf (stderr, "Entering new_itemsets, state = %d\n", nstates);      fprintf (stderr, "Entering new_itemsets, state = %d\n",
147                 this_state->number);
148    
149    for (i = 0; i < nsyms; i++)    for (i = 0; i < nsyms; i++)
150      kernel_end[i] = NULL;      kernel_end[i] = NULL;
# Line 192  new_state (int symbol) Line 187  new_state (int symbol)
187    core *p;    core *p;
188    
189    if (trace_flag)    if (trace_flag)
190      fprintf (stderr, "Entering new_state, state = %d, symbol = %d\n",      fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
191               nstates, symbol);               this_state->number, symbol, tags[symbol]);
192    
193    if (nstates >= MAXSHORT)    if (nstates >= MAXSHORT)
194      fatal (_("too many states (max %d)"), MAXSHORT);      fatal (_("too many states (max %d)"), MAXSHORT);
# Line 232  get_state (int symbol) Line 227  get_state (int symbol)
227    int n = kernel_end[symbol] - kernel_base[symbol];    int n = kernel_end[symbol] - kernel_base[symbol];
228    
229    if (trace_flag)    if (trace_flag)
230      fprintf (stderr, "Entering get_state, state = %d, symbol = %d\n",      fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
231               nstates, symbol);               this_state->number, symbol, tags[symbol]);
232    
233    /* Add up the target state's active item numbers to get a hash key.    /* Add up the target state's active item numbers to get a hash key.
234       */       */
# Line 276  get_state (int symbol) Line 271  get_state (int symbol)
271        state_table[key] = sp = new_state (symbol);        state_table[key] = sp = new_state (symbol);
272      }      }
273    
274      if (trace_flag)
275        fprintf (stderr, "Exiting get_state => %d\n", sp->number);
276    
277    return sp->number;    return sp->number;
278  }  }
279    
# Line 294  append_states (void) Line 292  append_states (void)
292    int symbol;    int symbol;
293    
294    if (trace_flag)    if (trace_flag)
295      fprintf (stderr, "Entering append_states\n");      fprintf (stderr, "Entering append_states, state = %d\n",
296                 this_state->number);
297    
298    /* first sort shift_symbol into increasing order */    /* first sort shift_symbol into increasing order */
299    

Legend:
Removed from v.1.15.2.8  
changed lines
  Added in v.1.15.2.9

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