Track node number so we can get unique node names
Track node to number mapping so we can get proper node name back
Generate DOT (graphviz) for a whole tree not just a node. For example, 3+4*5 should generate:
digraph { node [shape=plaintext, fixedsize=true, fontsize=11, fontname="Courier", width=.4, height=.2]; edge [arrowsize=.7] "+"->3 "+"->"" ""->4 "*"->5 }
Takes a Tree interface object.
Generated using TypeDoc
A utility class to generate DOT diagrams (graphviz) from arbitrary trees. You can pass in your own templates and can pass in any kind of tree or use Tree interface method. I wanted this separator so that you don't have to include ST just to use the org.antlr.runtime.tree.* package. This is a set of non-static methods so you can subclass to override. For example, here is an invocation:
CharStream input = new ANTLRInputStream(System.in); TLexer lex = new TLexer(input); CommonTokenStream tokens = new CommonTokenStream(lex); TParser parser = new TParser(tokens); TParser.e_return r = parser.e(); Tree t = (Tree)r.tree; System.out.println(t.toStringTree()); DOTTreeGenerator gen = new DOTTreeGenerator(); StringTemplate st = gen.toDOT(t); System.out.println(st);