[antlr-interest] How to get GUI like tree structure

Ketan Maheshwari ketancmaheshwari at gmail.com
Mon Mar 29 09:17:46 PDT 2010


Jim

Thanks again for your answer.

1. I checked the DOTTreeGenerator.java code but I do not seem to know how it
finds all the info about a tree. Also I am confused with its use of both the
stringtemplates and trees (are'nt they mutually exclusive?).

2. Yes, the toStringTree() method prints the tree but it only gives the leaf
nodes, that is the program itself. I have no info about which rule a given
token belongs to.

To be more clear, see the attached snapshot. My question is how can I
capture this parse tree in a some kind of java data structure and walk
through it.

Many Thanks again for all your help.

Ketan

On Mon, Mar 29, 2010 at 5:41 PM, Jim Idle <jimi at temporal-wave.com> wrote:

> Look at the code for DOTTreeGenerator.java or use toStringTree() if that
> gives you a good enough representation.
>
> Jim
>
> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> > bounces at antlr.org] On Behalf Of Ketan Maheshwari
> > Sent: Monday, March 29, 2010 7:36 AM
> > To: antlr-interest at antlr.org
> > Subject: [antlr-interest] How to get GUI like tree structure
> >
> > Hello Friends
> >
> > I am trying to use the CommonTree generated by the parser of my grammar
> > against a test code.
> >
> > Using the getChild(index).toString method, I get the tokens well.
> >
> > However, I do not know how can I also get a hierarchy of the rule to
> > which
> > they belong to. Similar to what we get in the ANTLRworks GUI.
> >
> > Any clue how can I get a tree such that it shows complete hierarchy of
> > the
> > grammar and the tokens as leaf nodes only.
> >
> > Am I using the correct Data Structure (CommonTree) ?
> >
> > Thanks for any clues.
> >
> > Regards
> > Ketan
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> > email-address
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree.png
Type: image/png
Size: 20997 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20100329/783ae2a5/attachment.png 


More information about the antlr-interest mailing list