From: Akim Demaille Date: Sun, 30 Jun 2002 17:31:37 +0000 (+0000) Subject: * src/state.h, src/state.c (shifts_to): New. X-Git-Tag: BISON-1_49b~108 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/24c7d80020623c5bfda79b5d55c18b4111389656?hp=9222837b2743308e4971fc0ad299ca2f73fb20ae * src/state.h, src/state.c (shifts_to): New. * src/lalr.c (build_relations): Use it. --- diff --git a/ChangeLog b/ChangeLog index ed8ec2ed..32efdc1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-06-30 Akim Demaille + + * src/state.h, src/state.c (shifts_to): New. + * src/lalr.c (build_relations): Use it. + + 2002-06-30 Akim Demaille * src/gram.h (rule_number_t, RULE_NUMBER_MAX, int_of_rule_number) diff --git a/src/lalr.c b/src/lalr.c index b1f84607..c3a55cc4 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -420,16 +420,8 @@ build_relations (void) for (rp = rules[*rulep].rhs; *rp >= 0; rp++) { - shifts_t *sp = state->shifts; - int j; - for (j = 0; j < sp->nshifts; j++) - { - state = states[sp->shifts[j]]; - if (state->accessing_symbol - == item_number_as_symbol_number (*rp)) - break; - } - + state = shifts_to (state->shifts, + item_number_as_symbol_number (*rp)); states1[length++] = state->number; } diff --git a/src/state.c b/src/state.c index dd8ec750..f365039d 100644 --- a/src/state.c +++ b/src/state.c @@ -49,6 +49,20 @@ shifts_new (int nshifts, state_number_t *shifts) } +/*-----------------------------------------------------------------. +| Return the state such these SHIFTS contain a shift/goto to it on | +| SYMBOL. Aborts if none found. | +`-----------------------------------------------------------------*/ + +state_t * +shifts_to (shifts_t *shifts, symbol_number_t s) +{ + int j; + for (j = 0; j < shifts->nshifts; j++) + if (SHIFT_SYMBOL (shifts, j) == s) + return states[shifts->shifts[j]]; + abort (); +} /*--------------------. diff --git a/src/state.h b/src/state.h index 074b1eea..674e1714 100644 --- a/src/state.h +++ b/src/state.h @@ -139,6 +139,10 @@ typedef struct shifts_s #define SHIFT_IS_DISABLED(Shifts, Shift) \ (Shifts->shifts[Shift] == 0) +/* Return the state such these SHIFTS contain a shift/goto to it on + SYMBOL. Aborts if none found. */ +struct state_s; +struct state_s *shifts_to PARAMS ((shifts_t *shifts, symbol_number_t s)); /*-------. | Errs. |