(reduce_output): This.
Output to OUT, passed as argument, instead of output_obstack.
(dump_grammar): Likewise.
(reduce_free): New.
Also free V1.
(reduce_grammar): No longer call reduce_output, since...
* src/print.c (print_results): do it.
* src/main.c (main): Call reduce_free;
+2001-11-12 Akim Demaille <akim@epita.fr>
+
+ * src/reduce.c (print_results): Rename as...
+ (reduce_output): This.
+ Output to OUT, passed as argument, instead of output_obstack.
+ (dump_grammar): Likewise.
+ (reduce_free): New.
+ Also free V1.
+ (reduce_grammar): No longer call reduce_output, since...
+ * src/print.c (print_results): do it.
+ * src/main.c (main): Call reduce_free;
+
2001-11-12 Akim Demaille <akim@epita.fr>
* src/conflicts.c (print_reductions): Accept OUT as argument.
Output to it, not to output_obstack.
* src/print.c (print_actions): Adjust.
2001-11-12 Akim Demaille <akim@epita.fr>
* src/conflicts.c (print_reductions): Accept OUT as argument.
Output to it, not to output_obstack.
* src/print.c (print_actions): Adjust.
2001-11-12 Akim Demaille <akim@epita.fr>
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts): Return
2001-11-12 Akim Demaille <akim@epita.fr>
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts): Return
* tests/regression.at (Invalid input): Remove, duplicate with
``Invalid input: 1''.
* tests/regression.at (Invalid input): Remove, duplicate with
``Invalid input: 1''.
2001-11-12 Akim Demaille <akim@epita.fr>
* tests/torture.at (AT_DATA_STACK_TORTURE)
2001-11-12 Akim Demaille <akim@epita.fr>
* tests/torture.at (AT_DATA_STACK_TORTURE)
/* Close the input files. */
close_files ();
/* Close the input files. */
close_files ();
free_conflicts ();
free_nullable ();
free_derives ();
free_conflicts ();
free_nullable ();
free_derives ();
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);
conflicts_output (out);
print_grammar (out);
conflicts_output (out);
print_grammar (out);
/* Grammar reduction for Bison.
/* Grammar reduction for Bison.
- Copyright 1988, 1989, 2000 Free Software Foundation, Inc.
+ Copyright 1988, 1989, 2000, 2001 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
-static void
-print_results (void)
+
+/*-----------------------------------------------------------------.
+| Ouput the detailed results of the reductions. For FILE.output. |
+`-----------------------------------------------------------------*/
+
+void
+reduce_output (FILE *out)
-/* short j; JF unused */
rule r;
bool b;
if (nuseless_nonterminals > 0)
{
rule r;
bool b;
if (nuseless_nonterminals > 0)
{
- obstack_sgrow (&output_obstack, _("Useless nonterminals:"));
- obstack_sgrow (&output_obstack, "\n\n");
+ fprintf (out, _("Useless nonterminals:"));
+ fprintf (out, "\n\n");
for (i = ntokens; i < nsyms; i++)
if (!BITISSET (V, i))
for (i = ntokens; i < nsyms; i++)
if (!BITISSET (V, i))
- obstack_fgrow1 (&output_obstack, " %s\n", tags[i]);
+ fprintf (out, " %s\n", tags[i]);
}
b = FALSE;
for (i = 0; i < ntokens; i++)
}
b = FALSE;
for (i = 0; i < ntokens; i++)
- obstack_sgrow (&output_obstack, "\n\n");
- obstack_sgrow (&output_obstack,
- _("Terminals which are not used:"));
- obstack_sgrow (&output_obstack, "\n\n");
+ fprintf (out, "\n\n");
+ fprintf (out, _("Terminals which are not used:"));
+ fprintf (out, "\n\n");
- obstack_fgrow1 (&output_obstack, " %s\n", tags[i]);
+ fprintf (out, " %s\n", tags[i]);
}
}
if (nuseless_productions > 0)
{
}
}
if (nuseless_productions > 0)
{
- obstack_sgrow (&output_obstack, "\n\n");
- obstack_sgrow (&output_obstack, _("Useless rules:"));
- obstack_sgrow (&output_obstack, "\n\n");
+ fprintf (out, "\n\n");
+ fprintf (out, _("Useless rules:"));
+ fprintf (out, "\n\n");
for (i = 1; i <= nrules; i++)
{
if (!BITISSET (P, i))
{
for (i = 1; i <= nrules; i++)
{
if (!BITISSET (P, i))
{
- obstack_fgrow1 (&output_obstack, "#%-4d ", i);
- obstack_fgrow1 (&output_obstack, "%s :\t", tags[rlhs[i]]);
+ fprintf (out, "#%-4d ", i);
+ fprintf (out, "%s :\t", tags[rlhs[i]]);
for (r = &ritem[rrhs[i]]; *r >= 0; r++)
for (r = &ritem[rrhs[i]]; *r >= 0; r++)
- obstack_fgrow1 (&output_obstack, " %s", tags[*r]);
- obstack_sgrow (&output_obstack, ";\n");
+ fprintf (out, " %s", tags[*r]);
+ fprintf (out, ";\n");
}
}
}
if (nuseless_nonterminals > 0 || nuseless_productions > 0 || b)
}
}
}
if (nuseless_nonterminals > 0 || nuseless_productions > 0 || b)
- obstack_sgrow (&output_obstack, "\n\n");
}
\f
#if 0 /* XXX currently unused. */
static void
}
\f
#if 0 /* XXX currently unused. */
static void
+dump_grammar (FILE *out)
- obstack_fgrow5 (&output_obstack,
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nitems = %d\n\n",
ntokens, nvars, nsyms, nrules, nitems);
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nitems = %d\n\n",
ntokens, nvars, nsyms, nrules, nitems);
- obstack_sgrow (&output_obstack,
- _("Variables\n---------\n\n"));
- obstack_sgrow (&output_obstack,
- _("Value Sprec Sassoc Tag\n"));
+ fprintf (out, _("Variables\n---------\n\n"));
+ fprintf (out, _("Value Sprec Sassoc Tag\n"));
for (i = ntokens; i < nsyms; i++)
for (i = ntokens; i < nsyms; i++)
- obstack_fgrow4 (&output_obstack,
- "%5d %5d %5d %s\n", i, sprec[i], sassoc[i], tags[i]);
- obstack_sgrow (&output_obstack, "\n\n");
- obstack_sgrow (&output_obstack, _("Rules\n-----\n\n"));
+ fprintf (out, "%5d %5d %5d %s\n", i, sprec[i], sassoc[i], tags[i]);
+ fprintf (out, "\n\n");
+ fprintf (out, _("Rules\n-----\n\n"));
for (i = 1; i <= nrules; i++)
{
for (i = 1; i <= nrules; i++)
{
- obstack_fgrow5 (&output_obstack, "%-5d(%5d%5d)%5d : (@%-5d)",
- i, rprec[i], rassoc[i], rlhs[i], rrhs[i]);
+ fprintf (out, "%-5d(%5d%5d)%5d : (@%-5d)",
+ i, rprec[i], rassoc[i], rlhs[i], rrhs[i]);
for (r = &ritem[rrhs[i]]; *r > 0; r++)
for (r = &ritem[rrhs[i]]; *r > 0; r++)
- obstack_fgrow1 (&output_obstack, "%5d", *r);
- obstack_fgrow1 (&output_obstack, " [%d]\n", -(*r));
+ fprintf (out, "%5d", *r);
+ fprintf (out, " [%d]\n", -(*r));
- obstack_sgrow (&output_obstack, "\n\n");
- obstack_sgrow (&output_obstack,
- _("Rules interpreted\n-----------------\n\n"));
+ fprintf (out, "\n\n");
+ fprintf (out, _("Rules interpreted\n-----------------\n\n"));
for (i = 1; i <= nrules; i++)
{
for (i = 1; i <= nrules; i++)
{
- obstack_fgrow2 (&output_obstack, "%-5d %s :", i, tags[rlhs[i]]);
+ fprintf (out, "%-5d %s :", i, tags[rlhs[i]]);
for (r = &ritem[rrhs[i]]; *r > 0; r++)
for (r = &ritem[rrhs[i]]; *r > 0; r++)
- obstack_fgrow1 (&output_obstack, " %s", tags[*r]);
- obstack_grow1 (&output_obstack, '\n');
+ fprintf (out, " %s", tags[*r]);
+ fputc ('\n', out);
- obstack_sgrow (&output_obstack, "\n\n");
+
+/*-------------------------------.
+| Report the results to STDERR. |
+`-------------------------------*/
+
{
if (yacc_flag && nuseless_productions)
fprintf (stderr, _("%d rules never reduced\n"), nuseless_productions);
{
if (yacc_flag && nuseless_productions)
fprintf (stderr, _("%d rules never reduced\n"), nuseless_productions);
reduced = (bool) (nuseless_nonterminals + nuseless_productions > 0);
reduced = (bool) (nuseless_nonterminals + nuseless_productions > 0);
- if (verbose_flag)
- print_results ();
-
- if (reduced == FALSE)
- goto done_reducing;
+ if (!reduced)
+ return;
if (!BITISSET (N, start_symbol - ntokens))
fatal (_("Start symbol %s does not derive any sentence"),
if (!BITISSET (N, start_symbol - ntokens))
fatal (_("Start symbol %s does not derive any sentence"),
#if 0
if (verbose_flag)
{
#if 0
if (verbose_flag)
{
- obstack_fgrow1 (&output_obstack, "REDUCED GRAMMAR\n\n");
+ fprintf (out, "REDUCED GRAMMAR\n\n");
dump_grammar ();
}
#endif
dump_grammar ();
}
#endif
(nvars == 1 ? "" : "s"),
nrules,
(nrules == 1 ? "" : "s"));
(nvars == 1 ? "" : "s"),
nrules,
(nrules == 1 ? "" : "s"));
-done_reducing:
- /* Free the global sets used to compute the reduced grammar */
+/*-----------------------------------------------------------.
+| Free the global sets used to compute the reduced grammar. |
+`-----------------------------------------------------------*/
+
+void
+reduce_free (void)
+{
/* Grammar reduction for Bison.
/* Grammar reduction for Bison.
- Copyright 2000 Free Software Foundation, Inc.
+ Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
# define REDUCE_H_
void reduce_grammar PARAMS ((void));
# define REDUCE_H_
void reduce_grammar PARAMS ((void));
+void reduce_output PARAMS ((FILE *out));
+void reduce_free PARAMS ((void));