[antlr-interest] If statement for Tree-based Interpreter: is it the correct way to do it?
Terence Parr
parrt at cs.usfca.edu
Thu Aug 23 11:31:32 PDT 2007
On Aug 23, 2007, at 11:02 AM, Pavel Ganelin wrote:
>
> Hi,
>
> I found that in ANTLR v3 it is more difficult to skip the child for
> tree walker compare with v2. Is it true or it is just learning curve?
>
> Below I attached how I process if statement for a tree-based
> interpreter. Please note that I had to add artificial token EOL
> while building the tree in the parser so that I could position the
> cursor just before Token.UP. I did not find a way to move the
> pointer to the last node of the the given tree ($s in the example
> below). Start and Stop indexes in the tree node point to the
> original token tree, not the CommonTreeNodeStream.
>
> Is it the way it is supposed to be implemented? If not what is the
> correct approach
>
> PS. I did read http://www.antlr.org/wiki/display/ANTLR3/Simple
> +tree-based+interpeter. It does not cover this question.
Hi Pavel,
From that page:
^(FUNC name=ID arg=ID .)
The dot skips the body subtree :)
Ter
More information about the antlr-interest
mailing list