Choosing the right parser for parsing C headers

Caleb Hattingh caleb1 at telkomsa.net
Tue Feb 8 23:15:59 EST 2005


Jean, Paddy

I use "pym" to extract bits of pascal out of delphi code for documentation  
purposes.  You have to add some stuff to the delphi code (in your case, C  
header), but these are added within comment blocks, and the interesting  
thing is that you add python code(!) as a kind of dynamic markup which pym  
executes while parsing the file.

In other words, you can write python code within a comment block in your  
C-header to generate unit-tests into other files, and get that code  
executed with pym.

Keep well
Caleb


On Tue, 08 Feb 2005 19:58:33 GMT, Paddy McCarthy <paddy3118x at netscape.net>  
wrote:

> 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 chose to make my UT-generator in Python 2.4. However, I am now
>> encountering problems in choosing the right parser for the job. I
>> struggle in choosing between the inappropriate, the out-of-date, the
>> alpha, or the too-big-for-the task...
>
> Why not see if the output from a tags file generator such as ctags or  
> etags will do what you want.
>
> I often find that some simpler tools do 95% of the work and it is easier  
> to treat the other five percent as broken-input.
>
> try http://ctags.sourceforge.net/
>
>
> - Paddy.




More information about the Python-list mailing list