Parsing a type definition using clang infrastructure

Hi Clangers,

First, apologies if this question has already been dealt with in the
mailing list archives, but my google-fu didn't reveal anything

I am the main developer of Dogen[1], a c++ code generator. At present
we have a _very_ basic hand-crafted boost::spirit parser [2] that
takes type definitions such as:


and converts it into the domain types we use for code generation.
However, as you can imagine, the parser is extremely limited - mostly
due to my limited boost::spirit knowledge, to be fair - which means we
are missing support for many useful c++ features. In addition, error
reporting is limited to "parses" or "parses not", which is not

So it seems time has come to start making use of the clang
infrastructure for this. I have been looking at the tutorials such as
loarabia's [3], but one thing I find in common with all tutorials up
till now is that they assume one needs all of the usual C++
infrastructure such as reading files, parsing includes and so on. I
was hoping to use just a parser with the smallest amount of
infrastructure around it. So my questions are:

- is this possible? i.e. use something like ParseExpr [4] to parse a
string in memory - or, if this is not the correct class, can you
please point me to the correct entry point.
- are there any examples of anyone going down such path that I could
use to get me started? I was hoping to find some unit tests but alas I
have failed so far.

Any other tips you may have are greatly appreciated. We will try to
submit a PR to loarabia's tutorial when we manage to get this working,
in case anyone else has such a need.

Many thanks for a fantastic tool and many thanks for your time.