[antlr-interest] Parsing any tree using tree grammer?

Randall R Schulz rschulz at sonic.net
Fri Jul 13 08:20:39 PDT 2007


On Friday 13 July 2007 07:23, Kamal Verma wrote:
> Hi All,
>
> Does anybody have thoughts parsing any tree of type "ITree" using
> tree grammar. Can this be done ? I looked at ITree interface,

What is ITree? org.antlr.Tree is the interface that must be implemented 
if a tree is to be parseable in an ANTLR tree parser, right?


> I was wondering is there any more simpler interface I can use to
> create parseable tree??

Well, Tree is not really an exceptionally complex interface to 
implement. If you already have a class or classes that are essentially 
tree-structureed, then you should write an adaptor class that makes 
that tree structure appear to the ANTLR tree parser like its Tree 
interface.

I don't think there's a way to short-cut that task.


> Something like,
> 
> interface ITree
> {
>       int ChildCount;
>      ITree getChild(int i);
> }
>
> Any thoughts ? comments ?
>
> -Kamal


Randall Schulz


More information about the antlr-interest mailing list