[antlr-interest] [v3] TreeParser capabilities
Emond Papegaaij
e.papegaaij at student.utwente.nl
Mon Nov 20 01:24:57 PST 2006
On Tuesday 14 November 2006 14:32, Emond Papegaaij wrote:
> For a research project I need some information about the capabilities of
> the TreeParser (for ANTLR v3). My application uses a custom TreeAdaptor,
> which constructs trees in a very different maner. The tree classes do not
> extend CommonTree, nor do they implement Tree.
>
> My first question: Is it possible to use a TreeParser with these nodes? It
> seems the TreeParser is based on a NodeStream, which presents the tree
> nodes to the TreeParser one by one. However only an implementation based on
> CommonTree is provided. What is needed to use a TreeParser with my custom
> TreeAdaptor? Do I need to write a TreeNodeStream based on a TreeAdaptor, or
> is such a stream already available?
It seems like there is currently no such stream. Is there a reason why
CommonTreeNodeStream is written based on the Tree interface, instead of using
a TreeAdaptor?
> My second question: Is it possible to skip sub-trees, or visit the same
> branch more than once (for example in an interpreter of a for statement)? I
> suspect that the NodeStream will get out-of-sync when you try to do so.
So far, I've not been able to skip children. A simple wildcard '.' seems to
match only a single node in the stream, and '^(.)' gives a syntax error.
Can anybody help me with this?
Best regards,
Emond
More information about the antlr-interest
mailing list