Java source code parser

跟風遠走 提交于 2019-12-04 07:10:26

Another option is Jflex and CUP. As per my usage experience, I liked the syntax more than ANTLR. However ANTLR scores more when it comes to IDE support and documentation..

ANTLR is a parser/generator that has grammars for Java (and other languages). It can produce an abstract syntax tree (AST) that you can navigate and manipulate as you wish.

if you look for a simple parser, i'd avise JavaParser (a much heavier implementation is also included in Eclipse)

Before going nuts with libraries, have you considered if Doclets could fit for your purposes? While meant for custom Javadoc parsing, Doclets actually get access to a lot of details about the classes themselves which can be used for whatever purpose.

Another similar not-exactly-intended possibility is the rather badly documented Annotation Processor functionality which, despite its name, can be used for plain code generation and general messing around and about within whatever you're loading through the class loaders.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!