From 9e7f6bbd5930d4d7365f65d33721cfbf651ca487 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 29 Dec 2001 14:15:12 +0000 Subject: [PATCH] * 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. --- ChangeLog | 10 ++++++++++ src/LR0.c | 2 +- src/gram.c | 6 +++--- src/nullable.c | 4 ++-- src/output.c | 2 +- src/print.c | 2 +- src/print_graph.c | 2 +- src/reduce.c | 6 +++--- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f29e7da..bb362090 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-12-29 Akim Demaille + + * 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 * src/output.c: Comment changes. diff --git a/src/LR0.c b/src/LR0.c index c1a0a8c1..3a036e84 100644 --- a/src/LR0.c +++ b/src/LR0.c @@ -391,7 +391,7 @@ void generate_states (void) { allocate_storage (); - new_closure (nitems); + new_closure (nritems); new_states (); while (this_state) diff --git a/src/gram.c b/src/gram.c index 219bbee5..6368051c 100644 --- a/src/gram.c +++ b/src/gram.c @@ -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++; } diff --git a/src/nullable.c b/src/nullable.c index 000b8b1b..bce291ca 100644 --- a/src/nullable.c +++ b/src/nullable.c @@ -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"); diff --git a/src/output.c b/src/output.c index ffeac28e..94ad4256 100644 --- a/src/output.c +++ b/src/output.c @@ -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)); diff --git a/src/print.c b/src/print.c index b893c5c9..90685ba0 100644 --- a/src/print.c +++ b/src/print.c @@ -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); diff --git a/src/print_graph.c b/src/print_graph.c index 0cdba5a1..506d2113 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -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 (); diff --git a/src/reduce.c b/src/reduce.c index 89ff3c3b..2b633c2a 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -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]; -- 2.47.2