* 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> 2001-12-29 Akim Demaille <akim@epita.fr>
* src/output.c: Comment changes. * src/output.c: Comment changes.

View File

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

View File

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

View File

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

View File

@@ -294,7 +294,7 @@ output_rule_data (void)
short_tab = XMALLOC (short, nrules + 1); short_tab = XMALLOC (short, nrules + 1);
for (i = 1; i < nrules; i++) for (i = 1; i < nrules; i++)
short_tab[i] = rule_table[i + 1].rhs - rule_table[i].rhs - 1; 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, output_table_data (&format_obstack, short_tab,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("r2", obstack_finish (&format_obstack)); 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 only its kernel. Requires to run closure, which need memory
allocation/deallocation. */ allocation/deallocation. */
if (trace_flag) if (trace_flag)
new_closure (nitems); new_closure (nritems);
/* Storage for print_reductions. */ /* Storage for print_reductions. */
shiftset = XCALLOC (unsigned, tokensetsize); shiftset = XCALLOC (unsigned, tokensetsize);
lookaheadset = XCALLOC (unsigned, tokensetsize); lookaheadset = XCALLOC (unsigned, tokensetsize);

View File

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

View File

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