diff -u -r branch-2.5/src/graphviz.c branch-2.5a/src/graphviz.c --- branch-2.5/src/graphviz.c 2010-05-02 23:04:16.000000000 +0200 +++ branch-2.5a/src/graphviz.c 2010-05-03 06:52:33.000000000 +0200 @@ -27,6 +27,9 @@ #include "files.h" #include "graphviz.h" +static int n_nodes = 0; +static int n_edges = 0; + /* Return an unambiguous printable representation for NAME, suitable for C strings. Use slot 2 since the user may use slots 0 and 1. */ @@ -39,10 +42,14 @@ void start_graph (FILE *fout) { + n_nodes = 0; + n_edges = 0; fprintf (fout, _("// Generated by %s.\n" "// Report bugs to <%s>.\n" "// Home page: <%s>.\n" + "// Shifts are solid, gotos are dashed, and error are dotted edge lines.\n" + "// Shifts are blue, gotos are green, and error are red colored edge lines.\n" "\n"), PACKAGE_STRING, PACKAGE_BUGREPORT, @@ -56,16 +63,18 @@ void output_node (int id, char const *label, FILE *fout) { - fprintf (fout, " %d [label=%s]\n", id, quote (label)); + n_nodes = n_nodes + 1; + fprintf (fout, " \"%d\" [label=%s]\n", id, quote (label)); } void output_edge (int source, int destination, char const *label, - char const *style, FILE *fout) + char const *style, char const *color, FILE *fout) { - fprintf (fout, " %d -> %d [style=%s", source, destination, style); + n_edges = n_edges + 1; + fprintf (fout, " \"%d\" -> \"%d\" [style=%s,color=\"%s\"", source, destination, style, color); if (label) - fprintf (fout, " label=%s", quote (label)); + fprintf (fout, ",label=%s", quote (label)); fputs ("]\n", fout); } @@ -73,4 +82,5 @@ finish_graph (FILE *fout) { fputs ("}\n", fout); + fprintf (fout, "// %d nodes and %d edges in this bison graph\n", n_nodes, n_edges); } diff -u -r branch-2.5/src/graphviz.h branch-2.5a/src/graphviz.h --- branch-2.5/src/graphviz.h 2010-04-12 01:19:35.000000000 +0200 +++ branch-2.5a/src/graphviz.h 2010-05-03 06:12:58.000000000 +0200 @@ -38,9 +38,10 @@ /// \param label human readable label of the edge /// (no Dot escaping needed). Can be 0. /// \param style Dot style of the edge (e.g., "dotted" or "solid"). +/// \param color Dot color of the edge (e.g., "red" or "green" or "blue"). /// \param fout output stream. void output_edge (int source, int destination, char const *label, - char const *style, FILE *fout); + char const *style, char const *color, FILE *fout); /// End a Dot graph. /// \param fout output stream. diff -u -r branch-2.5/src/print_graph.c branch-2.5a/src/print_graph.c --- branch-2.5/src/print_graph.c 2010-04-12 01:19:35.000000000 +0200 +++ branch-2.5a/src/print_graph.c 2010-05-03 06:08:01.000000000 +0200 @@ -134,12 +134,18 @@ : TRANSITION_IS_SHIFT (trans, i) ? "solid" : "dashed"); + /* Shifts are blue, gotos are green, and error is red. */ + char const *color = + (TRANSITION_IS_ERROR (trans, i) ? "red" + : TRANSITION_IS_SHIFT (trans, i) ? "blue" + : "green"); + if (TRANSITION_IS_ERROR (trans, i) && strcmp (symbols[sym]->tag, "error") != 0) abort (); output_edge (s->number, s1->number, TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag, - style, fgraph); + style, color, fgraph); } }