[antlr-interest] Parser - > Tree walker
Jim Idle
jimi at temporal-wave.com
Tue May 22 11:26:02 PDT 2007
IMO, the code you have shown here is less obvious than distinguishing
the semantic case in the tree generating parser, which actually involves
less typing and less knowledge.
Jim
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Andy Tripp
Sent: Tuesday, May 22, 2007 11:05 AM
To: CARLOS MELGAREJO
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Parser - > Tree walker
I'm sorry to keep doing this to the mailing list...I keep jumping in
once a month
with pretty much the same negative comment...but here goes anyway ;)
You're walking a tree-like data structure. You're at a '-' node, and you
want to distinguish
between the one with one child and the one with two children. IMO, if
you can't just
crank out the obvious code:
switch (node.getType()) {
case MINUS:
if (node.getChildCount() == 1) // unary
else // binary
break;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070522/81043469/attachment.html
More information about the antlr-interest
mailing list