21 static core **state_set;
22 static core *this_state;
23 static core *last_state;
28 static short *shift_symbol;
31 static short *shiftset;
33 static short **kernel_base;
34 static short **kernel_end;
35 static short *kernel_items;
37 static int get_state(
int symbol);
38 static void initialize_states(
void);
39 static void new_itemsets(
void);
40 static core *new_state(
int symbol);
41 static void save_shifts(
void);
42 static void save_reductions(
void);
44 static void print_derives(
void);
49 allocate_itemsets(
void)
63 for (itemp =
ritem; itemp < item_end; itemp++)
69 symbol_count[symbol]++;
74 kernel_items =
NEW2(count,
short);
78 for (i = 0; i <
nsyms; i++)
80 kernel_base[
i] = kernel_items + count;
81 count += symbol_count[
i];
82 if (max < symbol_count[i])
83 max = symbol_count[
i];
86 shift_symbol = symbol_count;
87 kernel_end =
NEW2(nsyms,
short *);
91 allocate_storage(
void)
94 shiftset =
NEW2(nsyms,
short);
107 fprintf(
stderr,
"Entering append_states()\n");
109 for (i = 1; i < nshifts; i++)
111 symbol = shift_symbol[
i];
113 while (j > 0 && shift_symbol[j - 1] > symbol)
115 shift_symbol[j] = shift_symbol[j - 1];
118 shift_symbol[j] = symbol;
121 for (i = 0; i < nshifts; i++)
123 symbol = shift_symbol[
i];
124 shiftset[
i] = get_state(symbol);
142 generate_states(
void)
160 this_state = this_state->
next;
170 get_state(
int symbol)
181 fprintf(
stderr,
"Entering get_state(%d)\n", symbol);
184 isp1 = kernel_base[symbol];
185 iend = kernel_end[symbol];
189 assert(0 <= key && key < nitems);
199 isp1 = kernel_base[symbol];
202 while (found && isp1 < iend)
204 if (*isp1++ != *isp2++)
217 sp = sp->
link = new_state(symbol);
225 state_set[key] = sp = new_state(symbol);
233 initialize_states(
void)
236 short *start_derives;
240 for (i = 0; start_derives[
i] >= 0; ++
i)
252 for (i = 0; start_derives[
i] >= 0; ++
i)
255 first_state = last_state = this_state = p;
268 for (i = 0; i <
nsyms; i++)
279 ksp = kernel_end[symbol];
282 shift_symbol[shiftcount++] = symbol;
283 ksp = kernel_base[symbol];
287 kernel_end[symbol] = ksp;
291 nshifts = shiftcount;
297 new_state(
int symbol)
306 fprintf(
stderr,
"Entering new_state(%d)\n", symbol);
310 fatal(
"too many states");
312 isp1 = kernel_base[symbol];
313 iend = kernel_end[symbol];
325 last_state->
next = p;
343 for (p = first_state; p; ++k, p = p->
next)
346 printf(
"state %d, number = %d, accessing symbol = %s\n",
349 for (i = 0; i < n; ++
i)
351 itemno = p->items[
i];
354 while (
ritem[j] >= 0) ++j;
360 while (ritem[j] >= 0)
396 for (p = first_shift; p; ++k, p = p->
next)
399 printf(
"shift %d, number = %d, nshifts = %d\n", k, p->number,
402 for (i = 0; i < j; ++
i)
403 printf(
"\t%d\n", p->shift[i]);
417 (nshifts - 1) *
sizeof(short)));
424 send = shiftset + nshifts;
431 last_shift->
next = p;
443 save_reductions(
void)
459 redset[count++] = -item;
466 (count - 1) *
sizeof(short)));
480 last_reduction->
next = p;
505 for (i = 0; i <
nrules; i++)
541 for (sp =
derives[i]; *sp >= 0; sp++)
562 for (i = 0; i <
nsyms; ++
i)
569 for (i = 1; i <
nitems; i++)
572 while ((j =
ritem[i]) >= 0)
591 for (i = 0; i <
nsyms; i++)
void fatal(char *msg) NORETURN
epics::pvData::BitSetPtr empty
#define assert(exp)
Declare that a condition should be true.
Internal: bucket item structure.
struct reductions reductions
reductions * first_reduction
void set_first_derives(void)
void finalize_closure(void)
char * allocate(unsigned int n)
void closure(short int *nucleus, int n)
void no_space(void) NORETURN