Search code examples
javaparsingbytecodeabstract-syntax-treevisitor-pattern

Java (or bytecode) AST generators available so that I can run a couple of Visitors on top of its result?


I am looking for a tool that'll take either a .java source code file, or .class or .jar and parses it, generating an AST(abstract syntax tree), so I can play with it. I intend to create a couple of Visitors to run on top of it.

Do such tools exist in Java? There exists something similar in .NET, called Mono.Cecil (although it seems that as of today, it's not supporting the Visitor pattern by itself).

Thanks


Solution

  • You might be interested in the ASTParser used by the Eclipse IDE. Here is a nice article on getting started with it.