Choosing the right parser for parsing C headers

John Machin sjmachin at lexicon.net
Tue Feb 8 18:49:12 EST 2005


Jean  de Largentaye wrote:
> Hi,
>
> I need to parse a subset of C (a header file), and generate some unit
> tests for the functions listed in it. I thus need to parse the code,
> then rewrite function calls with wrong parameters. What I call
"shaking
> the broken tree" :)

I was thinking "cdecl", and googling brought up this:

http://arrowtheory.com/software/python/

Another option, which I used recently when I had to parse a whole bunch
of Oracle 'create table' scripts [with semi-structured comments which
had to be mined for additional info]: write a recursive descent parser
-- but maybe the grammar of C function declarations is too complicated
for this.

HTH,
John




More information about the Python-list mailing list