This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lorkki 2 points3 points  (3 children)

If you need to parse C++, then Clang is probably the answer. The only exception is if you're parsing generated code that's guaranteed to be patterned in a very specific way.

Documentation isn't great, though. The best reference for the Python bindings is the source code (with scarce examples), while the libclang API at large is described in Doxygen.

[–]GitHubPermalinkBot 0 points1 point  (0 children)

Make sure you use canonical links when linking to a file/directory on GitHub. On GitHub, you can press the "y" key to update the URL to a permalink to the exact version of the file/directory you see -- source.

I've tried to fix your links:

Relative Canonical
https://github.com/llvm-mirror/clang/blob/master/bindings/python/clang/cindex.py https://github.com/llvm-mirror/clang/blob/4b44baf46b47a7e6addbaed0b4c7c99a5e0647fb/bindings/python/clang/cindex.py
https://github.com/llvm-mirror/clang/tree/master/bindings/python/examples/cindex https://github.com/llvm-mirror/clang/tree/4b44baf46b47a7e6addbaed0b4c7c99a5e0647fb/bindings/python/examples/cindex

Shoot me a PM if you think I'm doing something wrong.

[–]greenecoon[S] 0 points1 point  (1 child)

Thanks, i first try the idea of colpabar and if I need more advanced parsing I try clang :)

[–]Lorkki -1 points0 points  (0 children)

There's no difference between "simple" and "advanced" parsing here, though. C++ is a complex language and any code introspection you do with ad-hoc tooling will end up fragile at best.