mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 14:53:03 +00:00
Use hash.h for the state hash table.
* src/LR0.c (STATE_HASH_SIZE, state_hash): Remove. (allocate_storage): Use state_hash_new. (free_storage): Use state_hash_free. (new_state, get_state): Adjust. * src/lalr.h, src/lalr.c (states): Move to... * src/states.h (state_t): Remove the `link' member, no longer used. * src/states.h, src/states.c: here. (state_hash_new, state_hash_free, state_hash_lookup) (state_hash_insert, states_free): New. * src/states.c (state_table, state_compare, state_hash): New. * src/output.c (output_actions): Do not free states now, since we still need to know the final_state number in `prepare', called afterwards. Do it... * src/main.c (main): here: call states_free after `output'.
This commit is contained in:
21
src/state.h
21
src/state.h
@@ -44,10 +44,6 @@
|
||||
Each core contains a vector of NITEMS items which are the indices
|
||||
in the RITEMS vector of the items that are selected in this state.
|
||||
|
||||
The link field is used for chaining symbols that hash states by
|
||||
their itemsets. This is for recognizing equivalent states and
|
||||
combining them when the states are generated.
|
||||
|
||||
The two types of transitions are shifts (push the lookahead token
|
||||
and read another) and reductions (combine the last n things on the
|
||||
stack via a rule, replace them with the symbol that the rule
|
||||
@@ -180,7 +176,6 @@ reductions *reductions_new PARAMS ((int n));
|
||||
typedef struct state_s
|
||||
{
|
||||
struct state_s *next;
|
||||
struct state_s *link;
|
||||
|
||||
state_number_t number;
|
||||
symbol_number_t accessing_symbol;
|
||||
@@ -220,4 +215,20 @@ state_t *state_new PARAMS ((symbol_number_t accessing_symbol,
|
||||
void state_rule_lookaheads_print PARAMS ((state_t *state, rule_t *rule,
|
||||
FILE *out));
|
||||
|
||||
/* Create/destroy the states hash table. */
|
||||
void state_hash_new PARAMS ((void));
|
||||
void state_hash_free PARAMS ((void));
|
||||
|
||||
/* Find the state associated to the CORE, and return it. If it does
|
||||
not exist yet, return NULL. */
|
||||
state_t *state_hash_lookup PARAMS ((size_t core_size, item_number_t *core));
|
||||
|
||||
/* Insert STATE in the state hash table. */
|
||||
void state_hash_insert PARAMS ((state_t *state));
|
||||
|
||||
/* All the states, indexed by the state number. */
|
||||
extern state_t **states;
|
||||
|
||||
/* Free all the states. */
|
||||
void states_free PARAMS ((void));
|
||||
#endif /* !STATE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user