X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/0e78e603f696b4b820231b56fdb21c2a173e6bd3..c3b407f430a6c4bab6f0ef5160bb0c34290f3abb:/src/LR0.c diff --git a/src/LR0.c b/src/LR0.c index 47ce6dd2..02798cd9 100644 --- a/src/LR0.c +++ b/src/LR0.c @@ -1,5 +1,5 @@ /* Generate the nondeterministic finite state machine for bison, - Copyright 1984, 1986, 1989, 2000, 2001 Free Software Foundation, Inc. + Copyright 1984, 1986, 1989, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -23,6 +23,7 @@ The entry point is generate_states. */ #include "system.h" +#include "bitset.h" #include "symtab.h" #include "getargs.h" #include "reader.h" @@ -34,7 +35,7 @@ #include "lalr.h" #include "reduce.h" -int nstates; +unsigned int nstates; /* Initialize the final state to -1, otherwise, it might be set to 0 by default, and since we don't compute the reductions of the final state, we end up not computing the reductions of the initial state, @@ -113,6 +114,7 @@ allocate_storage (void) shiftset = XCALLOC (short, nsyms); redset = XCALLOC (short, nrules + 1); state_hash = XCALLOC (state_t *, STATE_HASH_SIZE); + shift_symbol = XCALLOC (short, nsyms); } @@ -154,7 +156,6 @@ new_itemsets (void) for (i = 0; i < nsyms; i++) kernel_size[i] = 0; - shift_symbol = XCALLOC (short, nsyms); nshifts = 0; for (i = 0; i < nitemset; ++i) @@ -188,7 +189,7 @@ new_state (int symbol) if (trace_flag) fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n", - this_state->number, symbol, tags[symbol]); + this_state->number, symbol, symbols[symbol]->tag); if (nstates >= MAXSHORT) fatal (_("too many states (max %d)"), MAXSHORT); @@ -227,7 +228,7 @@ get_state (int symbol) if (trace_flag) fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n", - this_state->number, symbol, tags[symbol]); + this_state->number, symbol, symbols[symbol]->tag); /* Add up the target state's active item numbers to get a hash key. */ @@ -364,15 +365,15 @@ save_reductions (void) } -/*--------------------. -| Build STATE_TABLE. | -`--------------------*/ +/*---------------. +| Build STATES. | +`---------------*/ static void -set_state_table (void) +set_states (void) { state_t *sp; - state_table = XCALLOC (state_t *, nstates); + states = XCALLOC (state_t *, nstates); for (sp = first_state; sp; sp = sp->next) { @@ -386,7 +387,7 @@ set_state_table (void) if (!sp->reductions) sp->reductions = reductions_new (0); - state_table[sp->number] = sp; + states[sp->number] = sp; } } @@ -406,7 +407,8 @@ generate_states (void) { if (trace_flag) fprintf (stderr, "Processing state %d (reached by %s)\n", - this_state->number, tags[this_state->accessing_symbol]); + this_state->number, + symbols[this_state->accessing_symbol]->tag); /* Set up ruleset and itemset for the transitions out of this state. ruleset gets a 1 bit for each rule that could reduce now. itemset gets a vector of all the items that could be @@ -431,6 +433,6 @@ generate_states (void) free_closure (); free_storage (); - /* Set up STATE_TABLE. */ - set_state_table (); + /* Set up STATES. */ + set_states (); }