[antlr-interest] ANTLR question

Bryan Ewbank ewbank at gmail.com
Mon Nov 7 13:30:34 PST 2005


Yes, that's exactly correct.  The implementation is a binary tree with
"left" meaning "child", and "right" meaning "sibling".  Also remember
that a sibling list /is/ a node (with a sibling), not a list.

If you draw your AST, then draw in the "1st child" and "next sibling"
relationshion, you will see that there is a binary tree (rotated 45
degrees :-).

What you are doing is exactly correct:
1. call getFirstChild() to start the list
2. call getNextSibling() repeatedly until it's null

The important thing to remember is to process the node, and not to
worry about the connectivities (unless you're doing tree
transformations :-).

Hope this helps,
- Bryan

On 11/7/05, bijoy thomas <bijoys_2000 at yahoo.com> wrote:
>
> I'm trying to cycle through the nodes of a sibling
> list by calling getFirstChild() on the root and then
> calling getNextSibling() on the returned nodes untill
> I get null.
>
> But the call to getFirstChild() is returning the whole
> sibling list itself.
>
> Thanks,
> Bijoy.
>
>
>
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
>


More information about the antlr-interest mailing list