* 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 (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
2001-11-30 Akim Demaille <akim@epita.fr>
* src/reduce.c (nonterminals_reduce): Instead of throwing away
void
conflicts_output (FILE *out)
{
void
conflicts_output (FILE *out)
{
+ bool printed_sth = FALSE;
int i;
for (i = 0; i < nstates; i++)
if (conflicts[i])
int i;
for (i = 0; i < nstates; i++)
if (conflicts[i])
fprintf (out, _("State %d contains "), i);
fputs (conflict_report (count_sr_conflicts (i),
count_rr_conflicts (i)), out);
fprintf (out, _("State %d contains "), i);
fputs (conflict_report (count_sr_conflicts (i),
count_rr_conflicts (i)), out);
+ if (printed_sth)
+ fputs ("\n\n", out);
static void
print_state (FILE *out, int state)
{
static void
print_state (FILE *out, int state)
{
fprintf (out, _("state %d"), state);
fputs ("\n\n", out);
print_core (out, state);
print_actions (out, state);
fprintf (out, _("state %d"), state);
fputs ("\n\n", out);
print_core (out, state);
print_actions (out, state);
}
\f
/*-----------------------------------------.
}
\f
/*-----------------------------------------.
int column = 0;
/* rule # : LHS -> RHS */
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. */
fprintf (out, " %s\n", _("Number, Line, Rule"));
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
fprintf (out, " /* %s */", _("empty"));
fputc ('\n', out);
}
fprintf (out, " /* %s */", _("empty"));
fputc ('\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]);
for (i = 0; i <= max_user_token_number; i++)
fprintf (out, "%s (-1)\n", tags[0]);
for (i = 0; i <= max_user_token_number; i++)
}
fprintf (out, "%s\n", buffer);
}
}
fprintf (out, "%s\n", buffer);
}
- 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;
for (i = ntokens; i <= nsyms - 1; i++)
{
int left_count = 0, right_count = 0;
}
fprintf (out, "%s\n", buffer);
}
}
fprintf (out, "%s\n", buffer);
}
size_t size = obstack_object_size (&output_obstack);
fwrite (obstack_finish (&output_obstack), 1, size, out);
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);
reduce_output (out);
conflicts_output (out);
void
reduce_output (FILE *out)
{
void
reduce_output (FILE *out)
{
- int i;
- rule r;
- bool b;
-
if (nuseless_nonterminals > 0)
{
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]);
for (i = 0; i < nuseless_nonterminals; ++i)
fprintf (out, " %s\n", tags[nsyms + i]);
- 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)
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]);
}
fprintf (out, " %s\n", tags[i]);
}
+ if (b)
+ fputs ("\n\n", out);
+ }
if (nuseless_productions > 0)
{
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))
{
for (i = 1; i <= nrules; i++)
if (!BITISSET (P, i))
{
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, "#%-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]);
- if (nuseless_nonterminals > 0 || nuseless_productions > 0 || b)
- fprintf (out, "\n\n");
-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,
AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0,
-[[Terminals which are not used:
useless1
useless2
useless3
useless1
useless2
useless3
AT_CHECK([cat input.output], [],
[[State 4 contains 1 shift/reduce conflict.
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
Grammar
Number, Line, Rule
1 3 exp -> exp OP exp
2 3 exp -> NUM
Terminals, with rules where they appear
$ (-1)
Terminals, with rules where they appear
$ (-1)
Nonterminals, with rules where they appear
exp (5)
Nonterminals, with rules where they appear
exp (5)
AT_CHECK([cat input.output], [],
[[Conflict in state 4 between rule 1 and token OP resolved as shift.
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
Grammar
Number, Line, Rule
1 4 exp -> exp OP exp
2 4 exp -> NUM
Terminals, with rules where they appear
$ (-1)
Terminals, with rules where they appear
$ (-1)
Nonterminals, with rules where they appear
exp (5)
Nonterminals, with rules where they appear
exp (5)
# Check the contents of the report.
AT_CHECK([cat input.output], [],
# Check the contents of the report.
AT_CHECK([cat input.output], [],
Number, Line, Rule
1 2 @1 -> /* empty */
Number, Line, Rule
1 2 @1 -> /* empty */
3 15 @2 -> /* empty */
4 15 expr -> @2 'c'
3 15 @2 -> /* empty */
4 15 expr -> @2 'c'
Terminals, with rules where they appear
$ (-1)
Terminals, with rules where they appear
$ (-1)
Nonterminals, with rules where they appear
expr (6)
Nonterminals, with rules where they appear
expr (6)