2011-09-25 01:33:04 +08:00
|
|
|
import org.antlr.v4.runtime.*;
|
|
|
|
import org.antlr.v4.runtime.tree.*;
|
2011-09-23 09:16:22 +08:00
|
|
|
|
|
|
|
public class TestU {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
ULexer t = new ULexer(new ANTLRFileStream(args[0]));
|
|
|
|
CommonTokenStream tokens = new CommonTokenStream(t);
|
|
|
|
UParser p = new UParser(tokens);
|
|
|
|
p.setBuildParseTrees(true);
|
|
|
|
UParser.aContext ctx = p.a();
|
|
|
|
|
|
|
|
System.out.println(((Tree) ctx.tree).toStringTree());
|
|
|
|
|
2011-09-25 01:33:04 +08:00
|
|
|
ASTNodeStream nodes = new CommonASTNodeStream(ctx.tree);
|
2011-09-23 09:16:22 +08:00
|
|
|
UWalker walker = new UWalker(nodes);
|
|
|
|
walker.a();
|
|
|
|
}
|
|
|
|
}
|