[antlr-interest] Good "dot" Invocation Options for Visualizing ASTs?
Jim Idle
jimi at temporal-wave.com
Mon Oct 6 08:54:02 PDT 2008
On Mon, 2008-10-06 at 08:46 -0700, Randall R Schulz wrote:
> 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.
These are not the defaults, they are the settings I use for this:
http://www.temporal-wave.com/comp/twcsc.php
> 2) Those are not the options I see when using DOTTreeGenerator in 3.1.1.
These are overrides, that you pass in here:
StringTemplate st = gen.toDOT(t, new CommonTreeAdaptor(), _treeST,
_edgeST);
> Actually, I'd prefer if all that were omitted, leaving only the graph
> structure itself,
So, pass in a string template that doesn't have those things in it and
just has "digraph {\n\n" + $edges + "\n{");
> 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)
Well, if they are not great, why not use the ones I just gave you, which
are pretty good? The code I sent is the entire invocation and a decent
template.
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081006/dd4a9359/attachment.html
More information about the antlr-interest
mailing list