mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 07:13:02 +00:00
Instead of mapping the LHS of unused rules to -1, keep the LHS
valid, but flag the rules as invalid. * src/gram.h (rule_t): `useful' is a new member. * src/print.c (print_grammar): Adjust. * src/derives.c (set_derives): Likewise. * src/reader.c (packgram, reduce_output): Likewise. * src/reduce.c (reduce_grammar_tables): Likewise. * tests/reduce.at (Underivable Rules, Useless Rules): New.
This commit is contained in:
@@ -63,7 +63,6 @@ void
|
||||
set_derives (void)
|
||||
{
|
||||
int i;
|
||||
int lhs;
|
||||
shorts *p;
|
||||
short *q;
|
||||
shorts **dset;
|
||||
@@ -74,16 +73,14 @@ set_derives (void)
|
||||
|
||||
p = delts;
|
||||
for (i = nrules; i > 0; i--)
|
||||
{
|
||||
lhs = rule_table[i].lhs;
|
||||
if (lhs >= 0)
|
||||
{
|
||||
p->next = dset[lhs];
|
||||
p->value = i;
|
||||
dset[lhs] = p;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
if (rule_table[i].useful)
|
||||
{
|
||||
int lhs = rule_table[i].lhs;
|
||||
p->next = dset[lhs];
|
||||
p->value = i;
|
||||
dset[lhs] = p;
|
||||
p++;
|
||||
}
|
||||
|
||||
derives = XCALLOC (short *, nvars) - ntokens;
|
||||
q = XCALLOC (short, nvars + nrules);
|
||||
|
||||
Reference in New Issue
Block a user