[antlr-interest] How to implement an IF
Terence Parr
parrt at cs.usfca.edu
Wed Dec 13 15:58:36 PST 2006
howdy Joerg, i just tweaked CommonTreeNodeStream to make rewind/
release work properly. The seek is there also (already I guess).
Wait, it says:
if ( index<this.index() ) {
throw new IllegalArgumentException("can't seek backwards
in node stream");
}
which is true. You can't seek backwards w/o knowing your state in
the past (whence the treestate objects). What we need for
interpreters is to do away with the small lookahead array and just
suck all tokens from CommonTreeNodeStream into an array like
CommonTokenStream does.
Perhaps we need another class BufferedTreeNodeStream that sucks from
a TreeNodeStream and buffers them so you can seek with an index
change. Make sense? If so, i'll build it real quick.
I also want to update this to use Object not Tree as the type of
nodes to be more generic.
Ter
More information about the antlr-interest
mailing list