Parsing C header files with python

Ian McConnell ian at emit.demon.co.uk
Sun Aug 22 14:03:21 EDT 2004


"Paul McGuire" <ptmcg at austin.rr._bogus_.com> writes:

> "Ian McConnell" <ian at emit.demon.co.uk> wrote in message
> news:873c2gzftf.fsf at emit.demon.co.uk...
>> I've got a header file which lists a whole load of C functions of the form
>>
>>   int func1(float *arr, int len, double arg1);
>>   int func2(float **arr, float *arr2, int len, double arg1, double arg2);
>>
>> It's a numerical library so all functions return an int and accept varying
>> combinations of float pointers, ints and doubles.
>>
>
> If regexp's give you pause, try this pyparsing example.  It makes heavy use
> of setting results names, so that the parsed tokens can be easily retrieved
> from the results as if they were named attributes.
>
> Download pyparsing at http://pyparsing.sourceforge.net.

Thanks. Your example with pyparsing was just what I was looking for. It also
copes very nicely with newlines and spacing in the header file.




More information about the Python-list mailing list