[antlr-interest] Best Approach/Suggestions?

Andreas Bartho andreas.bartho at inf.tu-dresden.de
Thu Sep 13 07:06:43 PDT 2007


Hi,

> (a) What exactly is the difference between a "grammar" and a "tree 
> grammar"?

With a grammar you create a parser that constructs a tree (AST) from
sequential input (tokens). A tree grammar creates a tree parser which
uses the AST as input and allows further processing. See section 4 in
http://www.antlr.org/wiki/display/ANTLR3/Parsing+XML

> (c) Is it possible to use something other than CommonTree but still use 
> the ANTLR tree construction operators?

You can use your own tree format. You have to write your own TreeAdaptor
(and give it to the parser before parsing). Use BaseTreeAdaptor and
CommonTreeAdaptor as guideline to get an idea what is going on.

Andreas



More information about the antlr-interest mailing list