Hi Joel, Here a patch on graphviz.c with maybe something interesting: - nodes are "1", "2" etc. because did not like using numbers as identifiers, now it are strings. - counter for number of nodes/edges and printing of it at end of graph file in c++ comment, for manual inspection to get some idea of the graph size and complexity. - colors again as it was done in the vcg graph output. - statement in header what the edge style/colors are about - edge attributes separated with ',' just as dot does it in the pdf documentation. (but can also be spaces) "137" -> "71" [style=solid,color="blue",label="\"char\""] - color between "" because it also can be other formats with numbers like "#112233" or color="0.002 0.999 0.999"
output is like this: // Generated by GNU Bison 2.4.502-bc81d-dirty. // Report bugs to <[email protected]>. // Home page: <http://www.gnu.org/software/bison/>. // Shifts are solid, gotos are dashed, and error are dotted edge lines. // Shifts are blue, gotos are green, and error are red colored edge lines. digraph "p.y" { "0" [label="0\n$accept -> . input \"end of file\""] "0" -> "1" [style=dashed,color="green",label="input"] ... "147" [label="147\nrhs -> rhs symbol named_ref.opt ."] } // 148 nodes and 283 edges in this bison graph attached patch.txt Thanks.
diff -r branch-2.5/src/graphviz.c branch-2.5a/src/graphviz.c 29a30,32 > static int n_nodes = 0; > static int n_edges = 0; > 41a45,46 > n_nodes = 0; > n_edges = 0; 45a51,52 > "// 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" 59c66,67 < fprintf (fout, " %d [label=%s]\n", id, quote (label)); --- > n_nodes = n_nodes + 1; > fprintf (fout, " \"%d\" [label=%s]\n", id, quote (label)); 64c72 < char const *style, FILE *fout) --- > char const *style, char const *color, FILE *fout) 66c74,75 < 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); 68c77 < fprintf (fout, " label=%s", quote (label)); --- > fprintf (fout, ",label=%s", quote (label)); 75a85 > fprintf (fout, "// %d nodes and %d edges in this bison graph\n", n_nodes, > n_edges); diff -r branch-2.5/src/graphviz.h branch-2.5a/src/graphviz.h 40a41 > /// \param color Dot color of the edge (e.g., "red" or "green" or > "blue"). 43c44 < char const *style, FILE *fout); --- > char const *style, char const *color, FILE *fout); diff -r branch-2.5/src/print_graph.c branch-2.5a/src/print_graph.c 136a137,142 > /* 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"); > 142c148 < style, fgraph); --- > style, color, fgraph);
