23 |
The entry point is generate_states. */ |
The entry point is generate_states. */ |
24 |
|
|
25 |
#include "system.h" |
#include "system.h" |
|
#include "xalloc.h" |
|
26 |
#include "gram.h" |
#include "gram.h" |
27 |
#include "state.h" |
#include "state.h" |
28 |
#include "complain.h" |
#include "complain.h" |
32 |
|
|
33 |
int nstates; |
int nstates; |
34 |
int final_state; |
int final_state; |
35 |
core *first_state; |
core *first_state = NULL; |
36 |
shifts *first_shift; |
shifts *first_shift = NULL; |
37 |
reductions *first_reduction; |
reductions *first_reduction = NULL; |
38 |
|
|
39 |
static core *this_state; |
static core *this_state = NULL; |
40 |
static core *last_state; |
static core *last_state = NULL; |
41 |
static shifts *last_shift; |
static shifts *last_shift = NULL; |
42 |
static reductions *last_reduction; |
static reductions *last_reduction = NULL; |
43 |
|
|
44 |
static int nshifts; |
static int nshifts; |
45 |
static short *shift_symbol; |
static short *shift_symbol = NULL; |
46 |
|
|
47 |
static short *redset; |
static short *redset = NULL; |
48 |
static short *shiftset; |
static short *shiftset = NULL; |
49 |
|
|
50 |
static short **kernel_base; |
static short **kernel_base = NULL; |
51 |
static short **kernel_end; |
static short **kernel_end = NULL; |
52 |
static short *kernel_items; |
static short *kernel_items = NULL; |
53 |
|
|
54 |
/* hash table for states, to recognize equivalent ones. */ |
/* hash table for states, to recognize equivalent ones. */ |
55 |
|
|
56 |
#define STATE_TABLE_SIZE 1009 |
#define STATE_TABLE_SIZE 1009 |
57 |
static core **state_table; |
static core **state_table = NULL; |
58 |
|
|
59 |
|
|
60 |
static void |
static void |
61 |
allocate_itemsets (void) |
allocate_itemsets (void) |
62 |
{ |
{ |
63 |
short *itemp; |
short *itemp = NULL; |
64 |
int symbol; |
int symbol; |
65 |
int i; |
int i; |
66 |
int count; |
int count; |
67 |
short *symbol_count; |
short *symbol_count = NULL; |
68 |
|
|
69 |
count = 0; |
count = 0; |
70 |
symbol_count = XCALLOC (short, nsyms); |
symbol_count = XCALLOC (short, nsyms); |
88 |
We allocate that much space for each symbol. */ |
We allocate that much space for each symbol. */ |
89 |
|
|
90 |
kernel_base = XCALLOC (short *, nsyms); |
kernel_base = XCALLOC (short *, nsyms); |
91 |
kernel_items = XCALLOC (short, count); |
if (count) |
92 |
|
kernel_items = XCALLOC (short, count); |
93 |
|
|
94 |
count = 0; |
count = 0; |
95 |
for (i = 0; i < nsyms; i++) |
for (i = 0; i < nsyms; i++) |