[cfe-users] Can I use clang to convert C/C++ code to a list of tokens?
kyle at ksluder.com
Wed Apr 16 11:05:59 PDT 2014
On Mon, Mar 31, 2014, at 08:32 PM, Ryan Cole wrote:
> Hi all,
> I'm wanting to take some C/C++ code and convert it to a list of tokens.
> Tokens that a compiler would use. I'm interested in the literal name of
> token, specifically. If I could get something that'd return to me
> along the lines of "this code you provided to me contains the following
> this order: variable, plus operator, minus operator, if statement start,
> statement end" etc. That is what I'm looking for.
> Is this something that I can use clang to help me with?
Yes. You might want to look at libclang, which exposes a C interface for
parsing source code.
More information about the cfe-users