Re:Measuring C API Coverage with Go
by SloopJon on Wednesday December 04, 2013 @12:29PM
(#6848470)
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.
Re:Measuring C API Coverage with Go
by jessevdk on Wednesday December 04, 2013 @12:42PM
(#6848589)
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.
Re:Measuring C API Coverage with Go
by unfamiliar on Wednesday December 04, 2013 @11:56AM
(#6848196)
To make this applicable to other APIs, wouldn't it be better to use the Clang API to parse the C/C++ code and get a list of functions? Writing your own parser seems prone to failure given the difficulty of C/C++ parsing.
Re:Measuring C API Coverage with Go
by dradtke on Wednesday December 04, 2013 @12:56PM
(#6848698)
Yeah, my approach is definitely one of "get it done as quickly as possible for my specific use case", and since Allegro made its headers easy to parse, I decided to just take advantage of that.
Maybe in the future I'll rewrite it to use libclang.
Re:Measuring C API Coverage with Go
by girvo on Wednesday December 04, 2013 @12:00PM
(#6848238)
Yeah. Has GCC built that feature in as well yet, or is the "plugin" side still pretty crippled? If one went about writing a nice generic tool like this, you'd want it to be able to handle both, I guess.
http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-....
(another shameless plug: libclang bindings are also available for Julia)
Maybe in the future I'll rewrite it to use libclang.