[antlr-interest] Evaluate the AST tree Twice

jack zhang jackgzhang2 at yahoo.com
Tue Feb 3 12:11:58 PST 2009


Hi,
  I need to walk the resulting ast tree twice with different tree parser. Is it possible ? I tried following code but it give me "NullPointerException".
 
// Build the tree...
QueryParser.start_return r = parser.parse();

// Walk the tree once...
CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree) r.getTree());
QueryTree walker = new QueryTree(nodes);
result = walker.start();

// Walk the tree with another treeparser. I got "Null Pointer Exception" here.
CommonTreeNodeStream nodes2= new CommonTreeNodeStream((Tree) r.getTree());
QueryTree walker = new QueryTree(nodes);
result = walker.start();


Is there some reseting or rewiding of tree pointer I need to do after the first iteration?

Thx !
-Jack


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090203/154617e5/attachment.html 


More information about the antlr-interest mailing list