exporting ASTs for Java

I am writing a Java program. I want it to read in and manipulate a Clang-generated AST. I am new to Clang, but from what I have learned so far, the best approach might be to have Clang export the AST in XML format (clang -cc1 -ast-print-xml foo.c) and have the Java program read in this XML. This will also require re-implementing many of the Clang AST classes in Java. I was wondering if some of you experienced Clangsters can give me some advice...

Does this seem like a reasonable approach?

Where can I find some documentation on the XML representation of the AST?

Is there an XML schema for the Clang AST XML representation?

Where should I start looking to learn more about Clang's AST classes in general?



We have -fobjc-rewrite which takes AST representation of objective-c program and translates into c++ code. Look at RewriteObjC.cpp file.

- Fariborz