diff options
Diffstat (limited to 'usr.bin/yacc/lr0.c')
-rw-r--r-- | usr.bin/yacc/lr0.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/usr.bin/yacc/lr0.c b/usr.bin/yacc/lr0.c index 43106ea6cf39..3a65effa0f6a 100644 --- a/usr.bin/yacc/lr0.c +++ b/usr.bin/yacc/lr0.c @@ -35,9 +35,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91"; +static char const sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91"; #endif /* not lint */ +#include <stdlib.h> #include "defs.h" extern short *itemset; @@ -49,8 +50,22 @@ core *first_state; shifts *first_shift; reductions *first_reduction; -int get_state(); -core *new_state(); +static void allocate_itemsets __P((void)); +static void allocate_storage __P((void)); +static void append_states __P((void)); +static void free_storage __P((void)); +static void generate_states __P((void)); +static int get_state __P((int)); +static void initialize_states __P((void)); +static void new_itemsets __P((void)); +static core *new_state __P((int)); +#ifdef DEBUG +static void print_derives __P((void)); +#endif +static void save_reductions __P((void)); +static void save_shifts __P((void)); +static void set_derives __P((void)); +static void set_nullable __P((void)); static core **state_set; static core *this_state; @@ -69,6 +84,7 @@ static short **kernel_end; static short *kernel_items; +static void allocate_itemsets() { register short *itemp; @@ -111,6 +127,7 @@ allocate_itemsets() } +static void allocate_storage() { allocate_itemsets(); @@ -120,6 +137,7 @@ allocate_storage() } +static void append_states() { register int i; @@ -149,6 +167,7 @@ append_states() } +static void free_storage() { FREE(shift_symbol); @@ -162,6 +181,7 @@ free_storage() +static void generate_states() { allocate_storage(); @@ -189,7 +209,7 @@ generate_states() -int +static int get_state(symbol) int symbol; { @@ -254,6 +274,7 @@ int symbol; +static void initialize_states() { register int i; @@ -281,6 +302,7 @@ initialize_states() } +static void new_itemsets() { register int i; @@ -317,7 +339,7 @@ new_itemsets() -core * +static core * new_state(symbol) int symbol; { @@ -356,6 +378,7 @@ int symbol; } +#if 0 /* show_cores is used for debugging */ show_cores() @@ -430,8 +453,10 @@ show_shifts() printf("\t%d\n", p->shift[i]); } } +#endif +static void save_shifts() { register shifts *p; @@ -466,6 +491,7 @@ save_shifts() +static void save_reductions() { register short *isp; @@ -515,6 +541,7 @@ save_reductions() } +static void set_derives() { register int i, k; @@ -545,13 +572,16 @@ set_derives() #endif } +#if 0 free_derives() { FREE(derives[start_symbol]); FREE(derives); } +#endif #ifdef DEBUG +static void print_derives() { register int i; @@ -574,6 +604,7 @@ print_derives() #endif +static void set_nullable() { register int i, j; @@ -623,12 +654,15 @@ set_nullable() } +#if 0 free_nullable() { FREE(nullable); } +#endif +void lr0() { set_derives(); |