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