mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
gram: fix and improve log message
It seems that not many people read these logs: the error was
introduced in 2001 (3067fbef53),
* src/gram.c (grammar_dump): Fix the headers of the table: remove
duplicate display of "Ritem Range".
While at it, remove duplicate display of the rule number (and remove
an incorrect comment about it: these numbers _are_ equal).
* tests/sets.at (Reduced Grammar): Use useless rule, nterm and token
in the example.
This commit is contained in:
14
src/gram.c
14
src/gram.c
@@ -274,25 +274,23 @@ grammar_dump (FILE *out, const char *title)
|
||||
|
||||
fprintf (out, "Rules\n-----\n\n");
|
||||
{
|
||||
/* Reduced number, then original number in the sources. */
|
||||
fprintf (out,
|
||||
"Num (Num, Prec, Assoc, Useful, UselessChain, Ritem Range)"
|
||||
" Lhs -> Rhs (Ritem range)\n");
|
||||
"Num (Prec, Assoc, Useful, UselessChain) Lhs"
|
||||
" -> (Ritem Range) Rhs\n");
|
||||
for (rule_number i = 0; i < nrules + nuseless_productions; ++i)
|
||||
{
|
||||
rule const *rule_i = &rules[i];
|
||||
unsigned const rhs_itemno = rule_i->rhs - ritem;
|
||||
unsigned length = rule_rhs_length (rule_i);
|
||||
fprintf (out, "%3d (%3d, %2d, %2d, %2s, %2s, %2u-%2u) %2d ->",
|
||||
item_number_as_rule_number (rule_i->rhs[length]),
|
||||
aver (item_number_as_rule_number (rule_i->rhs[length] == i));
|
||||
fprintf (out, "%3d (%2d, %2d, %2s, %2s) %2d -> (%2u-%2u)",
|
||||
i,
|
||||
rule_i->prec ? rule_i->prec->prec : 0,
|
||||
rule_i->prec ? rule_i->prec->assoc : 0,
|
||||
rule_i->useful ? "t" : "f",
|
||||
rule_useless_chain_p (rule_i) ? "t" : "f",
|
||||
rhs_itemno,
|
||||
rhs_itemno + length - 1,
|
||||
rule_i->lhs->number);
|
||||
rule_i->lhs->number,
|
||||
rhs_itemno, rhs_itemno + length - 1);
|
||||
/* Dumped the RHS. */
|
||||
for (item_number *rhsp = rule_i->rhs; 0 <= *rhsp; ++rhsp)
|
||||
fprintf (out, " %3d", *rhsp);
|
||||
|
||||
@@ -848,9 +848,10 @@ if test "$POSIXLY_CORRECT_IS_EXPORTED" = false; then
|
||||
|
||||
# Now check -Wnone and --warnings=none by making sure that
|
||||
# -Werror doesn't change the exit status when -Wnone or
|
||||
# --warnings=none is specified.
|
||||
]AT_BISON_CHECK_([$1[ -Wnone -Werror]], [[0]], [expout])[
|
||||
]AT_BISON_CHECK_([$1[ --warnings=none -Werror]], [[0]], [expout])[
|
||||
# --warnings=none is specified. With traces disabled, there should
|
||||
# be no output on stderr.
|
||||
]AT_BISON_CHECK_([$1[ -Wnone,none -Werror --trace=none]], [[0]], [expout])[
|
||||
]AT_BISON_CHECK_([$1[ --warnings=none -Werror --trace=none]], [[0]], [expout])[
|
||||
|
||||
]AT_RESTORE_SPECIAL_FILES[
|
||||
fi]dnl
|
||||
|
||||
@@ -315,34 +315,39 @@ AT_DATA([input.y],
|
||||
[[%%
|
||||
expr: expr "+" term | term
|
||||
term: term "*" fact | fact
|
||||
useless: "useless"
|
||||
fact: "num"
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[--trace=grammar -o input.c input.y]], [], [],
|
||||
[[Reduced Grammar
|
||||
[[input.y: warning: 1 nonterminal useless in grammar [-Wother]
|
||||
input.y: warning: 1 rule useless in grammar [-Wother]
|
||||
input.y:4.1-7: warning: nonterminal useless in grammar: useless [-Wother]
|
||||
Reduced Grammar
|
||||
|
||||
ntokens = 6, nvars = 4, nsyms = 10, nrules = 6, nritems = 17
|
||||
ntokens = 7, nvars = 4, nsyms = 11, nrules = 6, nritems = 17
|
||||
|
||||
Variables
|
||||
---------
|
||||
|
||||
Value Sprec Sassoc Tag
|
||||
6 0 0 $accept
|
||||
7 0 0 expr
|
||||
8 0 0 term
|
||||
9 0 0 fact
|
||||
7 0 0 $accept
|
||||
8 0 0 expr
|
||||
9 0 0 term
|
||||
10 0 0 fact
|
||||
|
||||
|
||||
Rules
|
||||
-----
|
||||
|
||||
Num (Num, Prec, Assoc, Useful, UselessChain, Ritem Range) Lhs -> Rhs (Ritem range)
|
||||
0 ( 0, 0, 0, t, f, 0- 1) 6 -> 7 0
|
||||
1 ( 1, 0, 0, t, f, 3- 5) 7 -> 7 3 8
|
||||
2 ( 2, 0, 0, t, t, 7- 7) 7 -> 8
|
||||
3 ( 3, 0, 0, t, f, 9-11) 8 -> 8 4 9
|
||||
4 ( 4, 0, 0, t, t, 13-13) 8 -> 9
|
||||
5 ( 5, 0, 0, t, t, 15-15) 9 -> 5
|
||||
Num (Prec, Assoc, Useful, UselessChain) Lhs -> (Ritem Range) Rhs
|
||||
0 ( 0, 0, t, f) 7 -> ( 0- 1) 8 0
|
||||
1 ( 0, 0, t, f) 8 -> ( 3- 5) 8 3 9
|
||||
2 ( 0, 0, t, t) 8 -> ( 7- 7) 9
|
||||
3 ( 0, 0, t, f) 9 -> ( 9-11) 9 4 10
|
||||
4 ( 0, 0, t, t) 9 -> (13-13) 10
|
||||
5 ( 0, 0, t, t) 10 -> (17-17) 6
|
||||
6 ( 0, 0, f, t) 11 -> (15-15) 5
|
||||
|
||||
|
||||
Rules interpreted
|
||||
@@ -354,9 +359,10 @@ Rules interpreted
|
||||
3 term: term "*" fact
|
||||
4 term: fact
|
||||
5 fact: "num"
|
||||
6 useless: "useless"
|
||||
|
||||
|
||||
reduced input.y defines 6 terminals, 4 nonterminals, and 6 productions.
|
||||
reduced input.y defines 7 terminals, 4 nonterminals, and 6 productions.
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user