/[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.61 by akim, Sun Apr 7 17:44:24 2002 UTC revision 1.62 by akim, Mon Apr 8 11:45:59 2002 UTC
# Line 56  static short *shift_symbol = NULL; Line 56  static short *shift_symbol = NULL;
56  static short *redset = NULL;  static short *redset = NULL;
57  static short *shiftset = NULL;  static short *shiftset = NULL;
58    
59  static short **kernel_base = NULL;  static item_number_t **kernel_base = NULL;
60  static int *kernel_size = NULL;  static int *kernel_size = NULL;
61  static short *kernel_items = NULL;  static item_number_t *kernel_items = NULL;
62    
63  /* hash table for states, to recognize equivalent ones.  */  /* hash table for states, to recognize equivalent ones.  */
64    
# Line 70  static void Line 70  static void
70  allocate_itemsets (void)  allocate_itemsets (void)
71  {  {
72    int i, r;    int i, r;
73    short *rhsp;    item_number_t *rhsp;
74    
75    /* Count the number of occurrences of all the symbols in RITEMS.    /* Count the number of occurrences of all the symbols in RITEMS.
76       Note that useless productions (hence useless nonterminals) are       Note that useless productions (hence useless nonterminals) are
# Line 92  allocate_itemsets (void) Line 92  allocate_itemsets (void)
92       appears as an item, which is symbol_count[symbol].       appears as an item, which is symbol_count[symbol].
93       We allocate that much space for each symbol.  */       We allocate that much space for each symbol.  */
94    
95    kernel_base = XCALLOC (short *, nsyms);    kernel_base = XCALLOC (item_number_t *, nsyms);
96    if (count)    if (count)
97      kernel_items = XCALLOC (short, count);      kernel_items = XCALLOC (item_number_t, count);
98    
99    count = 0;    count = 0;
100    for (i = 0; i < nsyms; i++)    for (i = 0; i < nsyms; i++)
# Line 194  new_state (int symbol) Line 194  new_state (int symbol)
194               nstates, symbol, quotearg_style (escape_quoting_style,               nstates, symbol, quotearg_style (escape_quoting_style,
195                                                symbols[symbol]->tag));                                                symbols[symbol]->tag));
196    
197    if (nstates >= MAXSHORT)    if (nstates >= SHRT_MAX)
198      fatal (_("too many states (max %d)"), MAXSHORT);      fatal (_("too many states (max %d)"), SHRT_MAX);
199    
200    p = STATE_ALLOC (kernel_size[symbol]);    p = STATE_ALLOC (kernel_size[symbol]);
201    p->accessing_symbol = symbol;    p->accessing_symbol = symbol;
202    p->number = nstates;    p->number = nstates;
203    p->nitems = kernel_size[symbol];    p->nitems = kernel_size[symbol];
204    
205    shortcpy (p->items, kernel_base[symbol], kernel_size[symbol]);    memcpy (p->items, kernel_base[symbol],
206              kernel_size[symbol] * sizeof (kernel_base[symbol][0]));
207    
208    /* 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
209       this is the final state.  */       this is the final state.  */
# Line 340  static void Line 341  static void
341  save_shifts (void)  save_shifts (void)
342  {  {
343    shifts *p = shifts_new (nshifts);    shifts *p = shifts_new (nshifts);
344    shortcpy (p->shifts, shiftset, nshifts);    memcpy (p->shifts, shiftset, nshifts * sizeof (shiftset[0]));
345    this_state->shifts = p;    this_state->shifts = p;
346  }  }
347    
# Line 372  save_reductions (void) Line 373  save_reductions (void)
373    
374    /* Make a reductions structure and copy the data into it.  */    /* Make a reductions structure and copy the data into it.  */
375    this_state->reductions = reductions_new (count);    this_state->reductions = reductions_new (count);
376    shortcpy (this_state->reductions->rules, redset, count);    memcpy (this_state->reductions->rules, redset, count * sizeof (redset[0]));
377  }  }
378    
379    

Legend:
Removed from v.1.61  
changed lines
  Added in v.1.62

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