From: Akim Demaille Date: Sat, 29 Dec 2001 14:16:46 +0000 (+0000) Subject: * src/gram.c (ritem_print): Be sure to subtract 1 when displaying X-Git-Tag: before-m4-back-end~72 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/29d29c8fff612552f253342caa5fcee70b713490 * src/gram.c (ritem_print): Be sure to subtract 1 when displaying rule line numbers. * src/closure.c (print_closure): Likewise. * src/derives.c (print_derives): Likewise. * tests/sets.at (Nullable): Adjust: the rule numbers are correct now. --- diff --git a/ChangeLog b/ChangeLog index e335f058..b8c23f74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-12-29 Akim Demaille + + * src/gram.c (ritem_print): Be sure to subtract 1 when displaying + rule line numbers. + * src/closure.c (print_closure): Likewise. + * src/derives.c (print_derives): Likewise. + * tests/sets.at (Nullable): Adjust: the rule numbers are correct + now. + 2001-12-29 Akim Demaille * src/lalr.c (lookaheads_print): New. diff --git a/src/closure.c b/src/closure.c index 45b85c68..4c8fcda7 100644 --- a/src/closure.c +++ b/src/closure.c @@ -62,7 +62,7 @@ print_closure (const char *title, short *array, size_t size) fprintf (stderr, " %2d: .", array[i]); for (rp = &ritem[array[i]]; *rp >= 0; ++rp) fprintf (stderr, " %s", tags[*rp]); - fprintf (stderr, " (rule %d)\n", -*rp); + fprintf (stderr, " (rule %d)\n", -*rp - 1); } fputs ("\n\n", stderr); } @@ -100,8 +100,8 @@ print_fderives (void) if (BITISSET (FDERIVES (i), j)) { short *rhsp; - fprintf (stderr, "\t\t%d:", j); - for (rhsp = ritem + rule_table[j].rhs; *rhsp >= 0; ++rhsp) + fprintf (stderr, "\t\t%d:", j - 1); + for (rhsp = &ritem[rule_table[j].rhs]; *rhsp >= 0; ++rhsp) fprintf (stderr, " %s", tags[*rhsp]); fputc ('\n', stderr); } diff --git a/src/derives.c b/src/derives.c index 8ca038f8..80e430bf 100644 --- a/src/derives.c +++ b/src/derives.c @@ -43,7 +43,7 @@ print_derives (void) { short *rhsp; fprintf (stderr, "\t\t%d:", *sp); - for (rhsp = ritem + rule_table[*sp].rhs; *rhsp >= 0; ++rhsp) + for (rhsp = &ritem[rule_table[*sp].rhs]; *rhsp >= 0; ++rhsp) fprintf (stderr, " %s", tags[*rhsp]); fprintf (stderr, " (rule %d)\n", -*rhsp - 1); } diff --git a/src/gram.c b/src/gram.c index 6368051c..4ec973c1 100644 --- a/src/gram.c +++ b/src/gram.c @@ -66,7 +66,7 @@ ritem_print (FILE *out) if (ritem[i] >= 0) fprintf (out, " %s", tags[ritem[i]]); else - fprintf (out, " (rule %d)\n", -ritem[i]); + fprintf (out, " (rule %d)\n", -ritem[i] - 1); fputs ("\n\n", out); } diff --git a/tests/sets.at b/tests/sets.at index f1c16dcf..cd2727a0 100644 --- a/tests/sets.at +++ b/tests/sets.at @@ -42,9 +42,9 @@ AT_CHECK([[bison --trace input.y]], [], [], [stderr]) AT_CHECK([[sed 's/[ ]*$//' stderr]], [], [[RITEM - e $ (rule 1) - 'e' (rule 2) - (rule 3) + e $ (rule 0) + 'e' (rule 1) + (rule 2) DERIVES @@ -89,12 +89,12 @@ FIRSTS FDERIVES $axiom derives - 1: e $ - 2: 'e' - 3: + 0: e $ + 1: 'e' + 2: e derives - 2: 'e' - 3: + 1: 'e' + 2: Processing state 0 (reached by $) @@ -102,9 +102,9 @@ Closure: input Closure: output - 0: . e $ (rule 1) - 3: . 'e' (rule 2) - 5: . (rule 3) + 0: . e $ (rule 0) + 3: . 'e' (rule 1) + 5: . (rule 2) Entering new_itemsets, state = 0 @@ -117,22 +117,22 @@ Entering new_state, state = 0, symbol = 5 (e) Exiting get_state => 2 Processing state 1 (reached by 'e') Closure: input - 4: . (rule 2) + 4: . (rule 1) Closure: output - 4: . (rule 2) + 4: . (rule 1) Entering new_itemsets, state = 1 Entering append_states, state = 1 Processing state 2 (reached by e) Closure: input - 1: . $ (rule 1) + 1: . $ (rule 0) Closure: output - 1: . $ (rule 1) + 1: . $ (rule 0) Entering new_itemsets, state = 2 @@ -142,11 +142,11 @@ Entering new_state, state = 2, symbol = 0 ($) Exiting get_state => 3 Processing state 3 (reached by $) Closure: input - 2: . (rule 1) + 2: . (rule 0) Closure: output - 2: . (rule 1) + 2: . (rule 0) Entering new_itemsets, state = 3