xml: match DOT output and xml2dot.xsl processing

Make the DOT produced by XSLT processing equivalent to the one made with the
--graph option.

* data/xslt/xml2dot.xsl: Stylistic changes, and add support for reductions.
* doc/bison.texi (Xml): Update.
* src/graphviz.c (conclude_red): Minor stylistic changes to DOT internals.
(output_red): Swap enabled and disabled reductions output, for coherence
with XSLT output.
* src/print_graph.c (print_core): Minor stylistic change to States' output.
(print_actions): Swap order of output for reductions and transitions.
* tests/local.at (AT_BISON_CHECK_XML): Ignore differences in order.
* tests/output.at: Adjust to changes in DOT internals.
This commit is contained in:
Theophile Ranquet
2012-10-23 15:43:54 +00:00
committed by Akim Demaille
parent 489b320d4a
commit be3517b007
7 changed files with 367 additions and 194 deletions

View File

@@ -106,7 +106,7 @@ conclude_red (struct obstack *out, int source, rule_number ruleno,
return (void) obstack_finish0 (out);
else
{
char const *ed = enabled ? "e" : "d";
char const *ed = enabled ? "" : "d";
char const *color = enabled ? ruleno ? "3" : "1" : "5";
/* First, build the edge's head. The name of reduction nodes is "nRm",
@@ -116,24 +116,28 @@ conclude_red (struct obstack *out, int source, rule_number ruleno,
fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [",
source, ruleno, ed);
/* (The lookahead tokens have been added to the beginning of the
obstack, in the caller function.) */
if (! obstack_empty_p (out))
/* (The lookahead tokens have been added to the beginning of the
obstack, in the caller function.) */
fprintf (fout, "label = \"[%s]\" ", obstack_finish0 (out));
{
char *label = obstack_finish0 (out);
fprintf (fout, "label=\"[%s]\", ", label);
obstack_free (out, label);
}
/* Then, the edge's tail. */
fprintf (fout, "style = solid]\n");
fprintf (fout, "style=solid]\n");
/* Build the associated diamond representation of the target rule. */
fprintf (fout, " \"%dR%d%s\" [style = filled, "
"shape = diamond, fillcolor = %s, ",
source, ruleno, ed, color);
if (ruleno)
fprintf (fout, "label = \"R%d\"]\n", ruleno);
fprintf (fout, " \"%dR%d%s\" [label=\"",
source, ruleno, ed);
if (ruleno)
fprintf (fout, "R%d", ruleno);
else
fprintf (fout, "label = \"Acc\"]\n");
fprintf (fout, "Acc");
fprintf (fout, "\", fillcolor=%s, shape=diamond, style=filled]\n",
color);
}
}
@@ -171,7 +175,7 @@ output_red (state const *s, reductions const *reds, FILE *fout)
bool defaulted = false;
bool firstd = true;
bool firste = true;
rule_number ruleno = reds->rules[j]->user_number;
rule_number ruleno = reds->rules[j]->number;
rule *default_reduction = NULL;
if (yydefact[s->number] != 0)
@@ -199,11 +203,11 @@ output_red (state const *s, reductions const *reds, FILE *fout)
}
/* Do the actual output. */
conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout);
conclude_red (&dout, source, ruleno, false, firstd, fout);
conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout);
}
obstack_free (&eout, 0);
obstack_free (&dout, 0);
obstack_free (&eout, 0);
bitset_free (no_reduce_set);
}

View File

@@ -76,7 +76,7 @@ print_core (struct obstack *oout, state *s)
}
obstack_printf (oout, _("State %d"), s->number);
obstack_sgrow (oout, "\\n");
obstack_sgrow (oout, "\\n\\l");
for (i = 0; i < snritems; i++)
{
item_number *sp;
@@ -142,9 +142,6 @@ print_actions (state const *s, FILE *fgraph)
transitions const *trans = s->transitions;
int i;
/* Display reductions. */
output_red (s, s->reductions, fgraph);
if (!trans->num && !s->reductions)
return;
@@ -167,6 +164,8 @@ print_actions (state const *s, FILE *fgraph)
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
style, fgraph);
}
/* Display reductions. */
output_red (s, s->reductions, fgraph);
}