mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
* src/LR0.c (allocate_itemsets): Don't loop over ritem: loop over
the RHS of the rules. * src/output.c (output_gram): Likewise.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2002-04-07 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/LR0.c (allocate_itemsets): Don't loop over ritem: loop over
|
||||||
|
the RHS of the rules.
|
||||||
|
* src/output.c (output_gram): Likewise.
|
||||||
|
|
||||||
2002-04-07 Akim Demaille <akim@epita.fr>
|
2002-04-07 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/gram.h (rule_t): `lhs' is now a pointer to the symbol's
|
* src/gram.h (rule_t): `lhs' is now a pointer to the symbol's
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ static state_t **state_hash = NULL;
|
|||||||
static void
|
static void
|
||||||
allocate_itemsets (void)
|
allocate_itemsets (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, r;
|
||||||
|
short *rhsp;
|
||||||
|
|
||||||
/* Count the number of occurrences of all the symbols in RITEMS.
|
/* Count the number of occurrences of all the symbols in RITEMS.
|
||||||
Note that useless productions (hence useless nonterminals) are
|
Note that useless productions (hence useless nonterminals) are
|
||||||
@@ -77,11 +78,11 @@ allocate_itemsets (void)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
short *symbol_count = XCALLOC (short, nsyms + nuseless_nonterminals);
|
short *symbol_count = XCALLOC (short, nsyms + nuseless_nonterminals);
|
||||||
|
|
||||||
for (i = 0; i < nritems; ++i)
|
for (r = 1; r < nrules + 1; ++r)
|
||||||
if (ritem[i] >= 0)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
symbol_count[ritem[i]]++;
|
symbol_count[*rhsp]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See comments before new_itemsets. All the vectors of items
|
/* See comments before new_itemsets. All the vectors of items
|
||||||
|
|||||||
18
src/output.c
18
src/output.c
@@ -202,14 +202,18 @@ output_gram (void)
|
|||||||
muscle_insert ("prhs", obstack_finish (&format_obstack));
|
muscle_insert ("prhs", obstack_finish (&format_obstack));
|
||||||
|
|
||||||
{
|
{
|
||||||
short *yyrhs;
|
short *rhsp;
|
||||||
int i;
|
int r;
|
||||||
|
int i = 0;
|
||||||
yyrhs = XMALLOC (short, nritems);
|
short *yyrhs = XMALLOC (short, nritems);
|
||||||
|
|
||||||
for (i = 1; i < nritems; ++i)
|
|
||||||
yyrhs[i] = ritem[i] >= 0 ? ritem[i] : -1;
|
|
||||||
|
|
||||||
|
for (r = 1; r < nrules + 1; ++r)
|
||||||
|
{
|
||||||
|
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
|
yyrhs[i++] = *rhsp;
|
||||||
|
yyrhs[i++] = -1;
|
||||||
|
}
|
||||||
|
assert (i == nritems);
|
||||||
output_table_data (&format_obstack, yyrhs,
|
output_table_data (&format_obstack, yyrhs,
|
||||||
ritem[0], 1, nritems);
|
ritem[0], 1, nritems);
|
||||||
muscle_insert ("rhs", obstack_finish (&format_obstack));
|
muscle_insert ("rhs", obstack_finish (&format_obstack));
|
||||||
|
|||||||
Reference in New Issue
Block a user