* src/conflicts.c (print_reductions): Accept OUT as argument.

Output to it, not to output_obstack.
* src/print.c (print_actions): Adjust.
This commit is contained in:
Akim Demaille
2001-11-12 09:32:35 +00:00
parent 0df87bb609
commit c73a41af8e
5 changed files with 22 additions and 17 deletions

View File

@@ -1,3 +1,10 @@
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> 2001-11-12 Akim Demaille <akim@epita.fr>
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts): Return * src/conflicts.c (count_sr_conflicts, count_rr_conflicts): Return

View File

@@ -502,7 +502,7 @@ conflicts_print (void)
void void
print_reductions (int state) print_reductions (FILE *out, int state)
{ {
int i; int i;
int j; int j;
@@ -580,9 +580,8 @@ print_reductions (int state)
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
{ {
if (mask & *fp3) if (mask & *fp3)
obstack_fgrow3 (&output_obstack, fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
_(" %-4s\t[reduce using rule %d (%s)]\n"), tags[i], default_rule, tags[rlhs[default_rule]]);
tags[i], default_rule, tags[rlhs[default_rule]]);
mask <<= 1; mask <<= 1;
if (mask == 0) if (mask == 0)
@@ -592,9 +591,8 @@ print_reductions (int state)
} }
} }
obstack_fgrow2 (&output_obstack, fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"),
_(" $default\treduce using rule %d (%s)\n\n"), default_rule, tags[rlhs[default_rule]]);
default_rule, tags[rlhs[default_rule]]);
} }
else if (n - m >= 1) else if (n - m >= 1)
{ {
@@ -681,7 +679,7 @@ print_reductions (int state)
if (j != default_LA) if (j != default_LA)
{ {
rule = LAruleno[j]; rule = LAruleno[j];
obstack_fgrow3 (&output_obstack, fprintf (out,
_(" %-4s\treduce using rule %d (%s)\n"), _(" %-4s\treduce using rule %d (%s)\n"),
tags[i], rule, tags[rlhs[rule]]); tags[i], rule, tags[rlhs[rule]]);
} }
@@ -695,13 +693,13 @@ print_reductions (int state)
if (defaulted) if (defaulted)
{ {
rule = LAruleno[default_LA]; rule = LAruleno[default_LA];
obstack_fgrow3 (&output_obstack, fprintf (out,
_(" %-4s\treduce using rule %d (%s)\n"), _(" %-4s\treduce using rule %d (%s)\n"),
tags[i], rule, tags[rlhs[rule]]); tags[i], rule, tags[rlhs[rule]]);
defaulted = 0; defaulted = 0;
} }
rule = LAruleno[j]; rule = LAruleno[j];
obstack_fgrow3 (&output_obstack, fprintf (out,
_(" %-4s\t[reduce using rule %d (%s)]\n"), _(" %-4s\t[reduce using rule %d (%s)]\n"),
tags[i], rule, tags[rlhs[rule]]); tags[i], rule, tags[rlhs[rule]]);
} }
@@ -722,11 +720,8 @@ print_reductions (int state)
} }
if (default_LA >= 0) if (default_LA >= 0)
obstack_fgrow2 (&output_obstack, fprintf (out, _(" $default\treduce using rule %d (%s)\n"),
_(" $default\treduce using rule %d (%s)\n"), default_rule, tags[rlhs[default_rule]]);
default_rule, tags[rlhs[default_rule]]);
obstack_1grow (&output_obstack, '\n');
} }
} }

View File

@@ -25,7 +25,7 @@
void solve_conflicts PARAMS ((void)); void solve_conflicts PARAMS ((void));
void conflicts_print PARAMS ((void)); void conflicts_print PARAMS ((void));
void conflicts_output PARAMS ((FILE *out)); void conflicts_output PARAMS ((FILE *out));
void print_reductions PARAMS ((int)); void print_reductions PARAMS ((FILE*out, int state));
void free_conflicts PARAMS ((void)); void free_conflicts PARAMS ((void));
/* Were there conflicts? */ /* Were there conflicts? */

View File

@@ -173,7 +173,7 @@ print_actions (FILE *out, int state)
} }
else if (redp) else if (redp)
{ {
print_reductions (state); print_reductions (out, state);
} }
if (i < k) if (i < k)

View File

@@ -123,6 +123,9 @@ state 4
OP shift, and go to state 3 OP shift, and go to state 3
OP [reduce using rule 1 (exp)]
$default reduce using rule 1 (exp)
state 5 state 5