mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
* src/nullable.c (set_nullable): Useless rules must be skipped,
otherwise, since we range over their symbols, we might look at a nonterminal which no longer ``exists'', i.e., it is not counted in `nvars', hence we overflow our arrays.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2001-12-15 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/nullable.c (set_nullable): Useless rules must be skipped,
|
||||||
|
otherwise, since we range over their symbols, we might look at a
|
||||||
|
nonterminal which no longer ``exists'', i.e., it is not counted in
|
||||||
|
`nvars', hence we overflow our arrays.
|
||||||
|
|
||||||
2001-12-15 Akim Demaille <akim@epita.fr>
|
2001-12-15 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/reader.c (copy_action): When --yacc, don't append a `;'
|
* src/reader.c (copy_action): When --yacc, don't append a `;'
|
||||||
|
|||||||
@@ -69,35 +69,38 @@ set_nullable (void)
|
|||||||
p = relts;
|
p = relts;
|
||||||
|
|
||||||
for (ruleno = 1; ruleno < nrules + 1; ++ruleno)
|
for (ruleno = 1; ruleno < nrules + 1; ++ruleno)
|
||||||
if (ritem[rule_table[ruleno].rhs] > 0)
|
if (rule_table[ruleno].useful)
|
||||||
{
|
{
|
||||||
/* This rule has a non empty RHS. */
|
if (ritem[rule_table[ruleno].rhs] > 0)
|
||||||
short *r;
|
|
||||||
int any_tokens = 0;
|
|
||||||
for (r = ritem + rule_table[ruleno].rhs; *r > 0; ++r)
|
|
||||||
if (ISTOKEN (*r))
|
|
||||||
any_tokens = 1;
|
|
||||||
|
|
||||||
/* This rule has only nonterminals: schedule it for the second
|
|
||||||
pass. */
|
|
||||||
if (!any_tokens)
|
|
||||||
for (r = ritem + rule_table[ruleno].rhs; *r > 0; ++r)
|
|
||||||
{
|
|
||||||
rcount[ruleno]++;
|
|
||||||
p->next = rsets[*r];
|
|
||||||
p->value = ruleno;
|
|
||||||
rsets[*r] = p;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This rule has an empty RHS. */
|
|
||||||
assert (ritem[rule_table[ruleno].rhs] == -ruleno);
|
|
||||||
if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
|
|
||||||
{
|
{
|
||||||
nullable[rule_table[ruleno].lhs] = 1;
|
/* This rule has a non empty RHS. */
|
||||||
*s2++ = rule_table[ruleno].lhs;
|
short *r;
|
||||||
|
int any_tokens = 0;
|
||||||
|
for (r = ritem + rule_table[ruleno].rhs; *r > 0; ++r)
|
||||||
|
if (ISTOKEN (*r))
|
||||||
|
any_tokens = 1;
|
||||||
|
|
||||||
|
/* This rule has only nonterminals: schedule it for the second
|
||||||
|
pass. */
|
||||||
|
if (!any_tokens)
|
||||||
|
for (r = ritem + rule_table[ruleno].rhs; *r > 0; ++r)
|
||||||
|
{
|
||||||
|
rcount[ruleno]++;
|
||||||
|
p->next = rsets[*r];
|
||||||
|
p->value = ruleno;
|
||||||
|
rsets[*r] = p;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This rule has an empty RHS. */
|
||||||
|
assert (ritem[rule_table[ruleno].rhs] == -ruleno);
|
||||||
|
if (rule_table[ruleno].useful && !nullable[rule_table[ruleno].lhs])
|
||||||
|
{
|
||||||
|
nullable[rule_table[ruleno].lhs] = 1;
|
||||||
|
*s2++ = rule_table[ruleno].lhs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user