Class<?> _return = classForName(parserName+"$"+testRuleName+"_return");
Method returnName = _return.getMethod("getTree");
CommonTree tree = (CommonTree) returnName.invoke(ruleReturn);
// Walk resulting tree; create tree nodes stream first
CommonTreeNodeStream nodes;
if ( customTreeAdaptor!=null ) {
nodes = new CommonTreeNodeStream(customTreeAdaptor, tree);
}
else {
nodes = new CommonTreeNodeStream(tree);
}
// AST nodes have payload that point into token stream
nodes.setTokenStream(tokens);
// Create a tree walker attached to the nodes stream
treeParser = classForName(treeParserPath).asSubclass(TreeParser.class);
Constructor<? extends TreeParser> treeParConstructor = treeParser.getConstructor(TreeNodeStream.class);
TreeParser treeParObj = treeParConstructor.newInstance(nodes); // makes new instance of tree parser
// Invoke the tree rule, and store the return value if there is