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" |
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; |
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 |
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; |
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); |
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 |
*/ |
*/ |
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 |
|
|
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 |
|
|