[antlr-interest] Looking for an example of tree walking using push/pop

Jeff Hair knifed at gmail.com
Thu Aug 4 13:01:32 PDT 2011


This has an example of how to go down the AST and then back up.

http://www.antlr.org/wiki/display/ANTLR3/Tree+pattern+matching

This is a concrete example of the method on the wiki. I used it in my
experiment about learning how to make an interpreter. EveCore calls the
downup method. The .g file is the grammar, of course.

https://github.com/ProjectMoon/eve2/blob/master/src/eve/core/EveCore.java#L227
https://github.com/ProjectMoon/eve2/blob/master/src/eve/core/ASTParser.g

On Thu, Aug 4, 2011 at 3:48 PM, <Janet.Hurwitz at usc-bt.com> wrote:

> Hello- I'm working on a grammar that has nested subtrees. I am successfully
> parsing the input to create the AST, but am having trouble navigating the
> tree to build the structure my Java program needs. The output is a
> HashMap<String,Object>.  When it's not a leaf node, the Object in the map
> will be a HashMap<String,Object>. Can you point me to some examples of more
> complicated tree walkers than the ones I've been able to find? I have been
> though the video tutorial as well. Thanks in advance.
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list