Java static source analysis/parsing (possibly with antlr), what is a good tool to do this?

Posted by Berlin Brown on Stack Overflow See other posts from Stack Overflow or by Berlin Brown
Published on 2010-05-28T16:23:19Z Indexed on 2010/05/28 16:32 UTC
Read the original article Hit count: 188

Filed under:
|
|
|
|

I need to perform static source analysis on Java code. Ideally, I want the system to work out of the box without much modification from me.

For example, I have used Antlr in the past, but I spent a lot of time building grammar files and still didn't get what I wanted.

I want to be able to parse a java file and have return the character position of say:

  1. Character position start and end of a Java block comment
  2. Character position start and end of a Java class file
  3. Character position start and end of a Java method declaration, signature, and implementation.

It looks like Antlr will do that, but I have yet to finish a grammar that actually gives me the positions of the code I need.

Does anyone have that complete Antlr grammar and Java code to give the character positions of the parts in the Java source.

© Stack Overflow or respective owner

Related posts about java

Related posts about parse