Here is a C# example which uses proparse.net.dll to print Proparse's syntax tree to the console:
using org.prorefactor.refactor;
using org.prorefactor.treeparser;
using System;
using System.Collections.Generic;
using System.Text;
using org.prorefactor.core;
namespace proparse.net {
class Program {
int indent = 0;
static void Main(string[] args) {
if (args.Length < 2) {
Console.WriteLine("Usage: TreePrint projectName fileName");
return;
}
new Program().run(args[0], args[1]);
}
void run(String projectName, String fileName) {
RefactorSession prsession = RefactorSession.getInstance();
// Disable parser serialization.
prsession.setProjectBinariesEnabledOff();
prsession.loadProject(projectName);
var f = new java.io.File(fileName);
if (! f.exists()) {
Console.WriteLine("Could not find file: " + fileName);
return;
}
ParseUnit pu = new ParseUnit(f);
pu.loadOrBuildPUB();
walker(pu.getTopNode());
}
void walker(JPNode node) {
if (node==null)
return;
for (int i = 0; i < indent; ++i)
Console.Write(" ");
Console.WriteLine(node.toString());
indent++;
walker(node.firstChild());
indent--;
walker(node.nextSibling());
}
}
}