On Mon, Jul 8, 2013 at 11:54 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</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 dir="auto">Generating correct Clang ASTs from anything but parsed C++ code is going to be extremely complicated. I think you’re better off generating C++ directly, or simply keeping your language front end separate from Clang.</div>

</blockquote><div><br></div><div>I've done this in a C++/CLI Clang implementation I've been working on. It generates AST nodes directly from .NET types read from assemblies. I would not say it was extremely complicated, but definitely tricky. There are a lot of things that are not obvious and you will only find out about them when the code crashes inside Clang internals, but if you're not afraid of debugging it's pretty doable.</div>

<div><br></div><div>In case anyone is interested to look at the code: <a href="https://github.com/tritao/clang/blob/master/lib/Sema/SemaCLI.cpp">https://github.com/tritao/clang/blob/master/lib/Sema/SemaCLI.cpp</a></div></div>

<div><br></div>-- <br>Joćo Matos