[antlr-interest] Multiple evaluations of the same tree

Hugo Picado hugo.pcd at gmail.com
Fri Jul 17 08:34:23 PDT 2009


Hi everyone,

I'm brand new to ANTLR. I didn't find any doubt similar.

Imagine a parser which the first rule is "prog", the output option is AST. I
created a tree walker to perform the tree evaluation but I need to evaluate
the same tree in a loop such as:

CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
LangWalker evaluator = new LangWalker(nodes);
for(int i = 0; i < 10000; i++)
        evaluator.rule();
end

As I understood, ANTLR consumes the stream so after the first
evaluator.rule() there is nothing more to consume and the code above
generates a null pointer exception (am I correct?). Is there any direct way
to solve this without having to recreate the tree (i.e. putting the first
two lines inside the loop) on each iteraction?

Best regards,
Hugo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090717/d665a634/attachment.html 


More information about the antlr-interest mailing list