83 |
static int nshifts; |
static int nshifts; |
84 |
static symbol_number_t *shift_symbol = NULL; |
static symbol_number_t *shift_symbol = NULL; |
85 |
|
|
86 |
static short *redset = NULL; |
static rule_t **redset = NULL; |
87 |
static state_number_t *shiftset = NULL; |
static state_t **shiftset = NULL; |
88 |
|
|
89 |
static item_number_t **kernel_base = NULL; |
static item_number_t **kernel_base = NULL; |
90 |
static int *kernel_size = NULL; |
static int *kernel_size = NULL; |
139 |
{ |
{ |
140 |
allocate_itemsets (); |
allocate_itemsets (); |
141 |
|
|
142 |
shiftset = XCALLOC (state_number_t, nsyms); |
shiftset = XCALLOC (state_t *, nsyms); |
143 |
redset = XCALLOC (short, nrules); |
redset = XCALLOC (rule_t *, nrules); |
144 |
state_hash_new (); |
state_hash_new (); |
145 |
shift_symbol = XCALLOC (symbol_number_t, nsyms); |
shift_symbol = XCALLOC (symbol_number_t, nsyms); |
146 |
} |
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
/*--------------------------------------------------------------. |
/*-----------------------------------------------------------------. |
208 |
| Find the state number for the state we would get to (from the | |
| Find the state we would get to (from the current state) by | |
209 |
| current state) by shifting symbol. Create a new state if no | |
| shifting SYMBOL. Create a new state if no equivalent one exists | |
210 |
| equivalent one exists already. Used by append_states. | |
| already. Used by append_states. | |
211 |
`--------------------------------------------------------------*/ |
`-----------------------------------------------------------------*/ |
212 |
|
|
213 |
static state_number_t |
static state_t * |
214 |
get_state (symbol_number_t symbol, size_t core_size, item_number_t *core) |
get_state (symbol_number_t symbol, size_t core_size, item_number_t *core) |
215 |
{ |
{ |
216 |
state_t *sp; |
state_t *sp; |
226 |
if (trace_flag) |
if (trace_flag) |
227 |
fprintf (stderr, "Exiting get_state => %d\n", sp->number); |
fprintf (stderr, "Exiting get_state => %d\n", sp->number); |
228 |
|
|
229 |
return sp->number; |
return sp; |
230 |
} |
} |
231 |
|
|
232 |
/*------------------------------------------------------------------. |
/*---------------------------------------------------------------. |
233 |
| Use the information computed by new_itemsets to find the state | |
| Use the information computed by new_itemsets to find the state | |
234 |
| numbers reached by each shift transition from STATE. | |
| numbers reached by each shift transition from STATE. | |
235 |
| | |
| | |
236 |
| SHIFTSET is set up as a vector of state numbers of those states. | |
| SHIFTSET is set up as a vector of those states. | |
237 |
`------------------------------------------------------------------*/ |
`---------------------------------------------------------------*/ |
238 |
|
|
239 |
static void |
static void |
240 |
append_states (state_t *state) |
append_states (state_t *state) |
292 |
{ |
{ |
293 |
int item = ritem[itemset[i]]; |
int item = ritem[itemset[i]]; |
294 |
if (item < 0) |
if (item < 0) |
295 |
redset[count++] = item_number_as_rule_number (item); |
redset[count++] = &rules[item_number_as_rule_number (item)]; |
296 |
} |
} |
297 |
|
|
298 |
/* Make a reductions structure and copy the data into it. */ |
/* Make a reductions structure and copy the data into it. */ |