On Mon, Dec 24, 2012 at 7:31 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">Longer explanation: I have not heard of anybody directly creating</div>
Clang AST's for a foreign language, and I don't think that the AST API<br>
is meant for doing that. If you want to directly build AST's, it<br>
should be relatively straightforward (at a high level) to just<br>
instantiate the AST classes (in include/clang/AST) and link them<br>
together in "appropriate ways". However, although I do not have superb<br>
knowledge of the AST, my belief is that you will run into a lot of<br>
"devil is in the details" problems due to unspoken invariants in the<br>
AST which makes "link them together in "appropriate ways"" very hard<br>
to achieve.</blockquote><div><br></div><div>I've done something like this. I create a (fake) AST from the metadata in .NET DLLs for an implementation of the C++/CLI standard. As you say the devil is in the details, and I had to read and debug lots of problems due to the rest of Clang expecting some AST invariants that are not exactly obvious. Still it's a nice approach since you get the rest of the compiler basically for free. You might have to extend the AST / IR gen to support some different details of your language, but overall I would say this approach works fine and saves you a lot of work.</div>

</div><br><br clear="all"><div><br></div>-- <br>Joćo Matos