Hacker News new | ask | show | jobs
by jessevdk 4576 days ago
Shameless plug (but possibly interesting), we do something similar (but using clang) to generate a coverage report for the gobject bindings for libgit2: https://git.gnome.org/browse/libgit2-glib/tree/tools/coverag...
1 comments

Wow. Although I was vaguely aware that Clang is tool friendly, I had no idea about libclang, let alone its Python bindings. A search for "python clang module" turned up a mention of pycparser. Any idea how it compares? I guess its main advantage is that it's pure Python.
Great introduction to libclang and cindex from Eli Bendersky:

http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-....

(another shameless plug: libclang bindings are also available for Julia)

I can't really compare, because I've personally never used pycparser. The nice thing about using libclang is that you're just using the same backend as the actual compiler and you can be sure that you're going to parse complex things correctly and reliably.