Class _return = Class.forName(parserPath+"$"+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 = Class.forName(treeParserPath);
Class[] treeParArgTypes = new Class[]{TreeNodeStream.class}; // assign type to tree parser's args
Constructor treeParConstructor = treeParser.getConstructor(treeParArgTypes);
Object[] treeParArgs = new Object[]{nodes}; // assign value to tree parser's args