4

I am writing a Mac OS X desktop application in which I want to be able to parse fragments of Objective-C such as variable and method declarations, as well as full Objective-C header and source files.

It looks to me as if I should be making use of Clang to do this, but I could do with some pointers and examples on how to integrate it as a library in my project, and how to invoke it to parse strings and files.

Can anyone provide me with any help on this?

1 Answer 1

4

You probably want libclang, code browsable at http://llvm.org/svn/llvm-project/cfe/trunk/tools/libclang/ (though you'll need to checkout the entire Clang repo to build it). There's very little documentation around on it, sadly. There is a presentation at http://llvm.org/devmtg/2010-11/Gregor-libclang.pdf that might help kickstart things, but mostly just some hunting through the code is the way to go.

Clang is actually more modular than libclang provides for (you can import just the components you want). If you've adventurous, there are examples at http://llvm.org/svn/llvm-project/cfe/trunk/examples/.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I've got the llvm and clang code checked out and built based on the info at clang.llvm.org/get_started.html, and I can see the tools/libclang directory with the header files I need. Now I need to figure out how to incorporate this into my Xcode 4.2 project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.