* src/LR0.c (generate_states): Use nritems, not nitems, nor using

the 0-sentinel.
* src/gram.c (ritem_longest_rhs): Likewise.
* src/reduce.c (nonterminals_reduce): Likewise.
* src/print_graph.c (print_graph): Likewise.
* src/output.c (output_rule_data): Likewise.
* src/nullable.c (set_nullable):  Likewise.
This commit is contained in:
Akim Demaille
2001-12-29 14:15:12 +00:00
parent 255ef6389e
commit 9e7f6bbd59
8 changed files with 22 additions and 12 deletions

View File

@@ -1,3 +1,13 @@
2001-12-29 Akim Demaille <akim@epita.fr>
* src/LR0.c (generate_states): Use nritems, not nitems, nor using
the 0-sentinel.
* src/gram.c (ritem_longest_rhs): Likewise.
* src/reduce.c (nonterminals_reduce): Likewise.
* src/print_graph.c (print_graph): Likewise.
* src/output.c (output_rule_data): Likewise.
* src/nullable.c (set_nullable): Likewise.
2001-12-29 Akim Demaille <akim@epita.fr>
* src/output.c: Comment changes.

View File

@@ -391,7 +391,7 @@ void
generate_states (void)
{
allocate_storage ();
new_closure (nitems);
new_closure (nritems);
new_states ();
while (this_state)

View File

@@ -78,14 +78,14 @@ ritem_print (FILE *out)
size_t
ritem_longest_rhs (void)
{
short *itemp;
int length;
int max;
int i;
length = 0;
max = 0;
for (itemp = ritem; *itemp; itemp++)
if (*itemp > 0)
for (i = 0; i < nritems; ++i)
if (ritem[i] >= 0)
{
length++;
}

View File

@@ -57,8 +57,8 @@ set_nullable (void)
Hence we must allocate room for useless nonterminals too. */
shorts **rsets = XCALLOC (shorts *, nvars) - ntokens;
/* This is said to be more elements than we actually use.
Supposedly nitems - nrules is enough. But why take the risk? */
shorts *relts = XCALLOC (shorts, nitems + nvars + 1);
Supposedly NRITEMS - NRULES is enough. But why take the risk? */
shorts *relts = XCALLOC (shorts, nritems + nvars + 1);
if (trace_flag)
fprintf (stderr, "Entering set_nullable\n");

View File

@@ -294,7 +294,7 @@ output_rule_data (void)
short_tab = XMALLOC (short, nrules + 1);
for (i = 1; i < nrules; i++)
short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1;
short_tab[nrules] = nitems - rule_table[nrules].rhs - 1;
short_tab[nrules] = nritems - rule_table[nrules].rhs - 1;
output_table_data (&format_obstack, short_tab,
0, 1, nrules + 1);
muscle_insert ("r2", obstack_finish (&format_obstack));

View File

@@ -495,7 +495,7 @@ print_results (void)
only its kernel. Requires to run closure, which need memory
allocation/deallocation. */
if (trace_flag)
new_closure (nitems);
new_closure (nritems);
/* Storage for print_reductions. */
shiftset = XCALLOC (unsigned, tokensetsize);
lookaheadset = XCALLOC (unsigned, tokensetsize);

View File

@@ -199,7 +199,7 @@ print_graph (void)
output_graph (&graph, fgraph);
/* Output nodes and edges. */
new_closure (nitems);
new_closure (nritems);
for (i = 0; i < nstates; i++)
print_state (state_table[i]);
free_closure ();

View File

@@ -383,9 +383,9 @@ nonterminals_reduce (void)
rule_table[i].precsym = nontermmap[rule_table[i].precsym];
}
for (r = ritem; *r; r++)
if (ISVAR (*r))
*r = nontermmap[*r];
for (i = 0; i < nritems; ++i)
if (ISVAR (ritem[i]))
ritem[i] = nontermmap[ritem[i]];
start_symbol = nontermmap[start_symbol];