Instead of attaching lookaheads and duplicating the rules being

reduced by a state, attach the lookaheads to the reductions.
* src/state.h (state_t): Remove the `lookaheads',
`lookaheads_rule' member.
(reductions_t): Add a `lookaheads' member.
Use a regular array for the `rules'.
* src/state.c (reductions_new): Initialize the lookaheads member
to 0.
(state_rule_lookaheads_print): Adjust.
* src/state.h, src/state.c (state_reductions_find): New.
* src/conflicts.c (resolve_sr_conflict, set_conflicts)
(count_rr_conflicts): Adjust.
* src/lalr.c (LArule): Remove.
(add_lookback_edge): Adjust.
(state_lookaheads_count): New.
(states_lookaheads_initialize): Merge into...
(initialize_LA): this.
(lalr_free): Adjust.
* src/main.c (main): Don't free nullable and derives too early: it
is used by --verbose.
* src/print.c, src/print_graph.c, src/tables.c: Adjust.
This commit is contained in:
Akim Demaille
2002-08-01 18:14:30 +00:00
parent bb0027a9ac
commit cd08e51eda
9 changed files with 228 additions and 240 deletions

View File

@@ -82,7 +82,7 @@
#ifndef STATE_H_
# define STATE_H_
# include "bitsetv.h"
# include "bitset.h"
/*-------------------.
@@ -178,6 +178,7 @@ errs_t *errs_new PARAMS ((int num, symbol_t **tokens));
typedef struct reductions_s
{
short num;
bitset *lookaheads;
rule_t *rules[1];
} reductions_t;
@@ -198,17 +199,6 @@ struct state_s
/* Nonzero if no lookahead is needed to decide what to do in state S. */
char consistent;
/* Used in LALR, not LR(0).
When a state is not consistent (there is an S/R or R/R conflict),
lookaheads are needed to enable the reductions. NLOOKAHEADS is
the number of lookahead guarded reductions of the
LOOKAHEADS_RULE. For each rule LOOKAHEADS_RULE[R], LOOKAHEADS[R]
is the bitset of the lookaheads enabling this reduction. */
int nlookaheads;
bitsetv lookaheads;
rule_t **lookaheads_rule;
/* If some conflicts were solved thanks to precedence/associativity,
a human readable description of the resolution. */
const char *solved_conflicts;
@@ -234,6 +224,8 @@ void state_transitions_set PARAMS ((state_t *state,
void state_reductions_set PARAMS ((state_t *state,
int num, rule_t **reductions));
int state_reduction_find PARAMS ((state_t *state, rule_t *rule));
/* Set the errs of STATE. */
void state_errs_set PARAMS ((state_t *state,
int num, symbol_t **errs));