From: Akim Demaille Date: Sat, 29 Dec 2001 14:16:59 +0000 (+0000) Subject: Fix the `GAWK Grammar' failure. X-Git-Tag: before-m4-back-end~71 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/610ab194c896d82708bc4c227115fd9832df6305 Fix the `GAWK Grammar' failure. * src/LR0.c (final_state): Initialize to -1 so that we do compute the reductions of the first state which was mistakenly confused with the final state because precisely final_state was initialized to 0. * tests/sets.at (Nullable): Adjust: state 0 does have lookaheads, now noticed by Bison. * tests/regression.at (Rule Line Numbers): Adjust: state 0 does have a reduction on $default. --- diff --git a/ChangeLog b/ChangeLog index b8c23f74..df65ef2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2001-12-29 Akim Demaille + + Fix the `GAWK Grammar' failure. + + * src/LR0.c (final_state): Initialize to -1 so that we do compute + the reductions of the first state which was mistakenly confused + with the final state because precisely final_state was initialized + to 0. + * tests/sets.at (Nullable): Adjust: state 0 does have lookaheads, + now noticed by Bison. + * tests/regression.at (Rule Line Numbers): Adjust: state 0 does + have a reduction on $default. + + 2001-12-29 Akim Demaille * src/gram.c (ritem_print): Be sure to subtract 1 when displaying diff --git a/src/LR0.c b/src/LR0.c index 3a036e84..b80cede7 100644 --- a/src/LR0.c +++ b/src/LR0.c @@ -34,7 +34,14 @@ #include "reduce.h" int nstates; -int final_state; +/* 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, + which is of course needed. + + FINAL_STATE is properly set by new_state when it recognizes the + accessing symbol: EOF. */ +int final_state = -1; static state_t *first_state = NULL; static state_t *this_state = NULL; diff --git a/tests/regression.at b/tests/regression.at index 937e5985..f6d8f102 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -328,6 +328,8 @@ state 0 'a' shift, and go to state 1 + $default reduce using rule 3 (@2) + expr go to state 2 @2 go to state 3 diff --git a/tests/sets.at b/tests/sets.at index cd2727a0..001fc4a8 100644 --- a/tests/sets.at +++ b/tests/sets.at @@ -158,7 +158,11 @@ transpose: output 0: Lookaheads: BEGIN -State 0: 0 lookaheads +State 0: 1 lookaheads + on 0 ($) -> rule -4 + on 1 (error) -> rule -4 + on 2 ($undefined.) -> rule -4 + on 3 ('e') -> rule -4 State 1: 0 lookaheads State 2: 0 lookaheads State 3: 0 lookaheads