Try to make the use of the eoftoken valid. Given that its value

is 0 which was also used as a sentinel in ritem, (i) make sure >= 0
is used instead of > 0 where appropriate, (ii), depend upon nritems
instead of the 0-sentinel.
* src/gram.h, src/gram.c (nritems): New.
Expected to be duplication of nitems, but for the time being...
* src/reader.c (packgram): Assert nritems and nitems are equal.
* src/LR0.c (allocate_itemsets, new_itemsets): Adjust.
* src/closure.c (print_closure, print_fderives): Likewise.
* src/gram.c (ritem_print): Likewise.
* src/print.c (print_core, print_grammar): Likewise.
* src/print_graph.c: Likewise.
This commit is contained in:
Akim Demaille
2001-12-27 18:13:31 +00:00
parent b7c49edf13
commit 75142d452b
9 changed files with 38 additions and 17 deletions

View File

@@ -60,7 +60,7 @@ print_closure (const char *title, short *array, size_t size)
{
short *rp;
fprintf (stderr, " %2d: .", array[i]);
for (rp = &ritem[array[i]]; *rp > 0; ++rp)
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
fprintf (stderr, " %s", tags[*rp]);
fprintf (stderr, " (rule %d)\n", -*rp);
}
@@ -101,7 +101,7 @@ print_fderives (void)
{
short *rhsp;
fprintf (stderr, "\t\t%d:", j);
for (rhsp = ritem + rule_table[j].rhs; *rhsp > 0; ++rhsp)
for (rhsp = ritem + rule_table[j].rhs; *rhsp >= 0; ++rhsp)
fprintf (stderr, " %s", tags[*rhsp]);
fputc ('\n', stderr);
}