/[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.85 by eggert, Wed Dec 11 05:29:17 2002 UTC revision 1.86 by eggert, Fri Dec 13 04:43:48 2002 UTC
# Line 1  Line 1 
1  /* Generate the nondeterministic finite state machine for bison,  /* Generate the nondeterministic finite state machine for Bison.
2    
3     Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002 Free Software     Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002 Free Software
4     Foundation, Inc.     Foundation, Inc.
# Line 59  static state_list *last_state = NULL; Line 59  static state_list *last_state = NULL;
59  static state *  static state *
60  state_list_append (symbol_number sym, size_t core_size, item_number *core)  state_list_append (symbol_number sym, size_t core_size, item_number *core)
61  {  {
62    state_list *node = XMALLOC (state_list, 1);    state_list *node = MALLOC (node, 1);
63    state *s = state_new (sym, core_size, core);    state *s = state_new (sym, core_size, core);
64    
65    if (trace_flag & trace_automaton)    if (trace_flag & trace_automaton)
# Line 106  allocate_itemsets (void) Line 106  allocate_itemsets (void)
106       browsed too, hence we need to allocate room for _all_ the       browsed too, hence we need to allocate room for _all_ the
107       symbols.  */       symbols.  */
108    int count = 0;    int count = 0;
109    short *symbol_count = XCALLOC (short, nsyms + nuseless_nonterminals);    short *symbol_count = CALLOC (symbol_count, nsyms + nuseless_nonterminals);
110    
111    for (r = 0; r < nrules; ++r)    for (r = 0; r < nrules; ++r)
112      for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)      for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
# Line 121  allocate_itemsets (void) Line 121  allocate_itemsets (void)
121       appears as an item, which is SYMBOL_COUNT[S].       appears as an item, which is SYMBOL_COUNT[S].
122       We allocate that much space for each symbol.  */       We allocate that much space for each symbol.  */
123    
124    kernel_base = XCALLOC (item_number *, nsyms);    CALLOC (kernel_base, nsyms);
125    if (count)    if (count)
126      kernel_items = XCALLOC (item_number, count);      CALLOC (kernel_items, count);
127    
128    count = 0;    count = 0;
129    for (i = 0; i < nsyms; i++)    for (i = 0; i < nsyms; i++)
# Line 133  allocate_itemsets (void) Line 133  allocate_itemsets (void)
133      }      }
134    
135    free (symbol_count);    free (symbol_count);
136    kernel_size = XCALLOC (int, nsyms);    CALLOC (kernel_size, nsyms);
137  }  }
138    
139    
# Line 142  allocate_storage (void) Line 142  allocate_storage (void)
142  {  {
143    allocate_itemsets ();    allocate_itemsets ();
144    
145    shiftset = XCALLOC (state *, nsyms);    CALLOC (shiftset, nsyms);
146    redset = XCALLOC (rule *, nrules);    CALLOC (redset, nrules);
147    state_hash_new ();    state_hash_new ();
148    shift_symbol = XCALLOC (symbol_number, nsyms);    CALLOC (shift_symbol, nsyms);
149  }  }
150    
151    
# Line 157  free_storage (void) Line 157  free_storage (void)
157    free (shiftset);    free (shiftset);
158    free (kernel_base);    free (kernel_base);
159    free (kernel_size);    free (kernel_size);
160    XFREE (kernel_items);    free (kernel_items);
161    state_hash_free ();    state_hash_free ();
162  }  }
163    
# Line 296  save_reductions (state *s) Line 296  save_reductions (state *s)
296  static void  static void
297  set_states (void)  set_states (void)
298  {  {
299    states = XCALLOC (state *, nstates);    CALLOC (states, nstates);
300    
301    while (first_state)    while (first_state)
302      {      {

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86

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