I believe it would be best to write some code against the Clang AST API to print the AST in a Rascal readable form. We use this strategy for other front-ends as well.
I.e. use the information in http://clang.llvm.org/docs/RAVFrontendAction.html to make a recursive AST visitor that prints things like:
ifStatement(intConstant(1),[])
After this you can read it in the AST using ValueIO
: readTextValueFile(#node, file)
, or you could use the ShellExec
library and readTextValueString
function.
This would give you a representation of the AST typed node
. If you want a typed representation, then also data declarations need to be generated, as in:
data Statement = ifStatement(Expression cond, list[Statement] body);
By the way, if anybody has written a JSON or XML exporter for Clang ASTs already, you would be king because there are libraries for Rascal to directly read in these formats.