[antlr-interest] Good "dot" Invocation Options for Visualizing ASTs?

Randall R Schulz rschulz at sonic.net
Mon Oct 6 08:46:53 PDT 2008


On Monday 06 October 2008 08:36, you wrote:
> On Mon, 2008-10-06 at 07:00 -0700, Randall R Schulz wrote:
> > Hi,
> >
> > Has anybody come up with good recipes for using the GraphViz
> > package's "dot" command for rendering the graphs of ASTs produced
> > by ANTLR 3 (.1.1)? If so, could you share? Or point me to resources
> > that would be me a head start on coming up with good incantations
> > of the dot command?
>
> it is built in to the Java and C runtimes. For Java:
>
>   public static StringTemplate _treeST =
>                 new StringTemplate(
> 			"digraph {\n" +
> 			"  ordering=out;\n" +
> 			"  ranksep=.4;\n" +
>             "  bgcolor=\"lightgrey\";" +
> 			"  node [shape=box, fixedsize=false, fontsize=12,
> fontname=\"Helvetica-bold\", fontcolor=\"blue\"\n" + "       
> width=.25, height=.25, color=\"black\", fillcolor=\"white\",
> style=\"filled, solid, bold\"];\n" + "  edge [arrowsize=.5,
> color=\"black\", style=\"bold\"]\n" + "  $nodes$\n" +
> 			"  $edges$\n" +
> 			"}\n");

A few things:

1) I don't get good results from the defaults.
2) Those are not the options I see when using DOTTreeGenerator in 3.1.1.

This is what I see at the top of all the DOT files written by the 
aforementioned class:

  ordering=out;
  ranksep=.4;
  node [shape=plaintext, fixedsize=true, fontsize=11,
        fontname="Courier", width=.25, height=.25];
  edge [arrowsize=.5]


Actually, I'd prefer if all that were omitted, leaving only the graph 
structure itself, and that the rendering options were left to the "dot" 
invocation. I have a cover script for invoking DOT that supplies 
defaults that I've concocted (they're not great, but they're much 
better than those shown above) plus it makes it easy (well, slightly 
easier than the "dot" CLI itself) to selectively modify those defaults.


> ...


Randall Schulz


More information about the antlr-interest mailing list