| Author |
Java source parsing/generation libraries
|
Marcin Moscicki
Greenhorn
Joined: Aug 12, 2005
Posts: 6
|
|
I am writing a tool, which output is a set of java source classes (*.java files). Although I got a first version working, I found that code generation is not a piece of cake - especially if you allow to specify snippets to include in the input and have to assert everything will compile, and, ideally, print it according to a given source formatting policy. This calls for a full syntactic tree. Do you now any libraries that would provide some or all of the following: - java code model classes for syntactic tree, like Clazz, Instruction, For, Declaration, Variable, etc; - methods for printing a given tree as source code to a stream; - methods for parsing streams and building that model tree ? Every IDE has to have implementations of the following, including open-source Eclipse, so I am half expecting it is already done and I could just use it after a resonable learning time. Any experiences or ideas for futher investigation path? Thanks,
|
1,000,000 lemmings can't be wrong!<br />mmoscicki@justimagine.pl
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
Eclipse indeed has this, ofcourse, in the JDT Core project. JDT Core is the Java infrastructure of the Java IDE. It includes: ... A Java Model that provides API for navigating the Java element tree. The Java element tree defines a Java centric view of a project. It surfaces elements like package fragments, compilation units, binary classes, types, methods, fields. Maybe it's worth to take a closer look if this is something you really need to do. You could also have a look at JavaCC, a Java parser generator. It includes a Java grammar as one of the examples (but only for Java 1.0 and 1.1...). If you search a little with Google, you'll find some other things like this one: JParse (I have no idea how useful or complete this is). [ August 02, 2006: Message edited by: Jesper Young ]
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Java source parsing/generation libraries
|
|
|