[antlr-interest] 'Catching' functions --

Martijn Reuvers martijn.reuvers at gmail.com
Mon Apr 19 01:05:37 PDT 2010


Hi William,

Depending on where you are when walking, lets say you're on FUNC_DECLR
(which is then the root of the tree). You could do something like:

Tree blockTree = funcDeclrTree.getChildAt(tree.getChildCount()-2) ;

In your case you just need the last child for block.

Martijn

On Sat, Apr 17, 2010 at 6:41 PM, William v Doorn
<williamvdoorn at gmail.com> wrote:
> Hello all,
>
> I'm writing a simple language where functions is a feature. To do this I
> need to somehow catch the tree of expressions/statements and execute it with
> the parameter(s) when it's needed. However, is it possible to create those
> trees when walking over the AST? Let's say I have this in the tree:
>
> ^(FUNC_DECL type ID formalParams? block)
>
> Is it possible to get the tree of the block? I only found this possible to
> do when building the AST (using $block.tree) but I can't seem to do this
> when walking over the AST.
>
> Thanks,
>
> William van Doorn
>
> 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