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/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.
2001-12-27 Paul Eggert <eggert@twinsun.com>
generate_states (void)
{
allocate_storage ();
- new_closure (nitems);
+ new_closure (nritems);
new_states ();
while (this_state)
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++;
}
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");
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));
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);
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 ();
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];