Hello,
I'm trying to make a tree walker for an if statement, in which the statement
part should of course only execute when the boolean expression part is true.
The problem is that in an example I found on the internet, I found that I
should use stream.push(...) and stream.pop() to insert tokens into
the stream that should be executed.
The problem is, getNodeIndex does not exist for CommonTreeNodeStream...but
how do I know the index which is needed for stream.push(index)?
ifstatement
@after {
CommonTree expressionNode = (CommonTree)$ifstatement.start.getChild(0);
CommonTree instructionlistNode = (CommonTree)$ifstatement.start.getChild(1);
if ($b.value == true)
{
System.out.println("LogoTree.g, ifstatement evaluates to true");
CommonTreeNodeStream stream = (CommonTreeNodeStream)input;
stream.push(stream.getNodeIndex(instructionlistNode));
instructionlist();
stream.pop();
}
}
: ^(IF b = booleanexpression .)
;
This does not work, since getNodeIndex does not exist for
CommonTreeNodeStream. Examples are rather scarce on the internet...something
this elemental should be more easy to implement, this has taken me days
now... Does anybody have any other ideas how to make an if statement? Any
help is greatly appreciated!
--
Regards,
Steven Raemaekers
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.