mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* src/reduce.c (reduce_output): Formatting changes.
* src/print.c (print_results, print_grammar): Likewise. * tests/regression.at (Rule Line Numbers) (Solved SR Conflicts, Unresolved SR Conflicts): Adjust.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2001-11-30 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/reduce.c (reduce_output): Formatting changes.
|
||||
* src/print.c (print_results, print_grammar): Likewise.
|
||||
* tests/regression.at (Rule Line Numbers)
|
||||
(Solved SR Conflicts, Unresolved SR Conflicts): Adjust.
|
||||
|
||||
2001-11-30 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/reduce.c (nonterminals_reduce): Instead of throwing away
|
||||
|
||||
@@ -419,6 +419,7 @@ conflict_report (int src_num, int rrc_num)
|
||||
void
|
||||
conflicts_output (FILE *out)
|
||||
{
|
||||
bool printed_sth = FALSE;
|
||||
int i;
|
||||
for (i = 0; i < nstates; i++)
|
||||
if (conflicts[i])
|
||||
@@ -426,7 +427,10 @@ conflicts_output (FILE *out)
|
||||
fprintf (out, _("State %d contains "), i);
|
||||
fputs (conflict_report (count_sr_conflicts (i),
|
||||
count_rr_conflicts (i)), out);
|
||||
printed_sth = TRUE;
|
||||
}
|
||||
if (printed_sth)
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
16
src/print.c
16
src/print.c
@@ -181,11 +181,11 @@ print_actions (FILE *out, int state)
|
||||
static void
|
||||
print_state (FILE *out, int state)
|
||||
{
|
||||
fputs ("\n\n", out);
|
||||
fprintf (out, _("state %d"), state);
|
||||
fputs ("\n\n", out);
|
||||
print_core (out, state);
|
||||
print_actions (out, state);
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
/*-----------------------------------------.
|
||||
@@ -212,7 +212,7 @@ print_grammar (FILE *out)
|
||||
int column = 0;
|
||||
|
||||
/* rule # : LHS -> RHS */
|
||||
fprintf (out, "\n%s\n\n", _("Grammar"));
|
||||
fprintf (out, "%s\n\n", _("Grammar"));
|
||||
fprintf (out, " %s\n", _("Number, Line, Rule"));
|
||||
for (i = 1; i <= nrules; i++)
|
||||
/* Don't print rules disabled in reduce_grammar_tables. */
|
||||
@@ -228,9 +228,11 @@ print_grammar (FILE *out)
|
||||
fprintf (out, " /* %s */", _("empty"));
|
||||
fputc ('\n', out);
|
||||
}
|
||||
fputs ("\n\n", out);
|
||||
|
||||
|
||||
/* TERMINAL (type #) : rule #s terminal is on RHS */
|
||||
fprintf (out, "\n%s\n\n", _("Terminals, with rules where they appear"));
|
||||
fprintf (out, "%s\n\n", _("Terminals, with rules where they appear"));
|
||||
fprintf (out, "%s (-1)\n", tags[0]);
|
||||
|
||||
for (i = 0; i <= max_user_token_number; i++)
|
||||
@@ -252,9 +254,10 @@ print_grammar (FILE *out)
|
||||
}
|
||||
fprintf (out, "%s\n", buffer);
|
||||
}
|
||||
fputs ("\n\n", out);
|
||||
|
||||
fprintf (out, "\n%s\n\n",
|
||||
_("Nonterminals, with rules where they appear"));
|
||||
|
||||
fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
|
||||
for (i = ntokens; i <= nsyms - 1; i++)
|
||||
{
|
||||
int left_count = 0, right_count = 0;
|
||||
@@ -309,6 +312,7 @@ print_grammar (FILE *out)
|
||||
}
|
||||
fprintf (out, "%s\n", buffer);
|
||||
}
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -324,6 +328,8 @@ print_results (void)
|
||||
|
||||
size_t size = obstack_object_size (&output_obstack);
|
||||
fwrite (obstack_finish (&output_obstack), 1, size, out);
|
||||
if (size)
|
||||
fputs ("\n\n", out);
|
||||
|
||||
reduce_output (out);
|
||||
conflicts_output (out);
|
||||
|
||||
40
src/reduce.c
40
src/reduce.c
@@ -407,50 +407,46 @@ nonterminals_reduce (void)
|
||||
void
|
||||
reduce_output (FILE *out)
|
||||
{
|
||||
int i;
|
||||
rule r;
|
||||
bool b;
|
||||
|
||||
if (nuseless_nonterminals > 0)
|
||||
{
|
||||
fprintf (out, _("Useless nonterminals:"));
|
||||
fprintf (out, "\n\n");
|
||||
int i;
|
||||
fprintf (out, "%s\n\n", _("Useless nonterminals:"));
|
||||
for (i = 0; i < nuseless_nonterminals; ++i)
|
||||
fprintf (out, " %s\n", tags[nsyms + i]);
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
b = FALSE;
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
|
||||
{
|
||||
bool b = FALSE;
|
||||
int i;
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (!BITISSET (V, i) && !BITISSET (V1, i))
|
||||
{
|
||||
if (!b)
|
||||
{
|
||||
fprintf (out, "\n\n");
|
||||
fprintf (out, _("Terminals which are not used:"));
|
||||
fprintf (out, "\n\n");
|
||||
b = TRUE;
|
||||
}
|
||||
fprintf (out, "%s\n\n", _("Terminals which are not used:"));
|
||||
b = TRUE;
|
||||
fprintf (out, " %s\n", tags[i]);
|
||||
}
|
||||
}
|
||||
if (b)
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
if (nuseless_productions > 0)
|
||||
{
|
||||
fprintf (out, "\n\n");
|
||||
fprintf (out, _("Useless rules:"));
|
||||
fprintf (out, "\n\n");
|
||||
int i;
|
||||
fprintf (out, "%s\n\n", _("Useless rules:"));
|
||||
for (i = 1; i <= nrules; i++)
|
||||
if (!BITISSET (P, i))
|
||||
{
|
||||
rule r;
|
||||
fprintf (out, "#%-4d ", i);
|
||||
fprintf (out, "%s :\t", tags[rule_table[i].lhs]);
|
||||
for (r = &ritem[rule_table[i].rhs]; *r >= 0; r++)
|
||||
fprintf (out, " %s", tags[*r]);
|
||||
fprintf (out, ";\n");
|
||||
fputs (";\n", out);
|
||||
}
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
if (nuseless_nonterminals > 0 || nuseless_productions > 0 || b)
|
||||
fprintf (out, "\n\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -44,10 +44,12 @@ AT_DATA([[input.y]],
|
||||
exp: useful;
|
||||
]])
|
||||
|
||||
AT_CHECK([[bison input.y]])
|
||||
AT_CHECK([[bison input.y]], 0, [],
|
||||
[[input.y contains 9 useless nonterminals
|
||||
]])
|
||||
|
||||
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
|
||||
[[Terminals which are not used:
|
||||
[[Useless nonterminals:
|
||||
useless1
|
||||
useless2
|
||||
useless3
|
||||
|
||||
@@ -63,12 +63,14 @@ AT_CHECK([bison input.y -o input.c -v], 0, [],
|
||||
AT_CHECK([cat input.output], [],
|
||||
[[State 4 contains 1 shift/reduce conflict.
|
||||
|
||||
|
||||
Grammar
|
||||
|
||||
Number, Line, Rule
|
||||
1 3 exp -> exp OP exp
|
||||
2 3 exp -> NUM
|
||||
|
||||
|
||||
Terminals, with rules where they appear
|
||||
|
||||
$ (-1)
|
||||
@@ -76,6 +78,7 @@ error (256)
|
||||
NUM (257) 2
|
||||
OP (258) 1
|
||||
|
||||
|
||||
Nonterminals, with rules where they appear
|
||||
|
||||
exp (5)
|
||||
@@ -138,6 +141,8 @@ state 5
|
||||
state 6
|
||||
|
||||
$default accept
|
||||
|
||||
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -162,12 +167,14 @@ AT_CHECK([bison input.y -o input.c -v], 0, [], [])
|
||||
AT_CHECK([cat input.output], [],
|
||||
[[Conflict in state 4 between rule 1 and token OP resolved as shift.
|
||||
|
||||
|
||||
Grammar
|
||||
|
||||
Number, Line, Rule
|
||||
1 4 exp -> exp OP exp
|
||||
2 4 exp -> NUM
|
||||
|
||||
|
||||
Terminals, with rules where they appear
|
||||
|
||||
$ (-1)
|
||||
@@ -175,6 +182,7 @@ error (256)
|
||||
NUM (257) 2
|
||||
OP (258) 1
|
||||
|
||||
|
||||
Nonterminals, with rules where they appear
|
||||
|
||||
exp (5)
|
||||
@@ -236,6 +244,8 @@ state 5
|
||||
state 6
|
||||
|
||||
$default accept
|
||||
|
||||
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -283,8 +293,7 @@ AT_CHECK([bison input.y -o input.c -v], 0, [], [])
|
||||
|
||||
# Check the contents of the report.
|
||||
AT_CHECK([cat input.output], [],
|
||||
[[
|
||||
Grammar
|
||||
[[Grammar
|
||||
|
||||
Number, Line, Rule
|
||||
1 2 @1 -> /* empty */
|
||||
@@ -292,6 +301,7 @@ Grammar
|
||||
3 15 @2 -> /* empty */
|
||||
4 15 expr -> @2 'c'
|
||||
|
||||
|
||||
Terminals, with rules where they appear
|
||||
|
||||
$ (-1)
|
||||
@@ -300,6 +310,7 @@ $ (-1)
|
||||
'c' (99) 4
|
||||
error (256)
|
||||
|
||||
|
||||
Nonterminals, with rules where they appear
|
||||
|
||||
expr (6)
|
||||
@@ -378,6 +389,8 @@ state 7
|
||||
state 8
|
||||
|
||||
$default accept
|
||||
|
||||
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user