Hacker News new | ask | show | jobs
Ask HN: Parser for Java
3 points by live_to_code 6169 days ago
I've done google searches, and generally get back Parser Generators in Java / how to write Parsers in Java.

What I want instead, is just a single industrial parser that can parse Java source code (like anything that the jvm can run). (Doing some really simple static analysis stuff).

Is there anything "official" that's easy to modify, like a parser from Sun or IBM or eclipse?

Thanks!

4 comments

I believe that one of the ANTLR examples (as provided in the source download), is a Java parser. http://www.antlr.org/
Are you looking for JavaCC? https://javacc.dev.java.net/
>> industrial parser that can parse Java source code (like anything that the jvm can run)

Do you mean a parser for Java source code or bytecode? I would guess the former, but the reference to "anything that the jvm can run" suggests you may be looking for bytecode...

Java source code.
Eclipse has the JDT package which gives you access to the parser that Eclipse uses internally.
Ah; this is closest to what I want; though if I can use the Sun one Sun uses for javac, it'd be even better.
Yes, Javac is open source. You can't get any more official than that. http://openjdk.java.net/groups/compiler/