C source viewer/mapper?

Bengt Richter bokr at oz.net
Sun Dec 22 22:57:19 EST 2002


On Mon, 23 Dec 2002 13:50:55 +1100, "Simon Burton" <simonb at webone.com.au> wrote:

>On Fri, 20 Dec 2002 04:50:57 +0000, noc wrote:
>
>> I have a c program that I want to replace with a python script.
>> 
>> But I don't know c all that well. What I'd like to is look at a visual map
>> of the c program, a flowchart that draws that subroutines as blocks, points
>> out what variables traverse the blocks, and highlights external traffic to
>> sockets and ports.
>> 
>> A basic google search comes up empty, in spite of the fact that I'm not the
>> first to want such a thing. Thinkgeek offers a linux kernel map poster that
>> was generated by perl scripts.
>> 
>> So I guess that means roll my own, which means building a c interpreter, by
>> which time I'll have relearnt enough c to read the code in the first place,
>> but producing code is much cooler than simply reading code.
>> 
>> So, does anybody have any hints or pointers to hints that would help on this
>> mad errand?
>> 
>> Thanks
>> Bruce
>
>I am working on a c code parser written in python right now.
>My main focus is parsing .h files to generate wrapper code for python 
>(yes i know about SWIG), but i hope it will do a lot more, such
>as general "explaining" that you (and many others) would like.
>
>highlighting external traffic to sockets is somewhat specific,
>but my hope is that a well written python c-parser will allow for
>custom extensions without to much hassle.
>
>let me know if you're interested; i'll announce something on c.l.py 
>soon i hope,

Are you doing it based on a Grammar file like Python's

    D:\Python-2.2.2\Grammar\Grammar

file? Do you know if there are free grammars around that work with the Python stuff?
Some commercial flex/bison type tools advertise big lists of language grammars,
but I haven't googled for open source grammars per se. The other obvious question
is if there's an automated format conversion between the two. Flex by itself can
handle lots of conditional stuff (I defined a custom HTML parser using it which goes
pretty quick, being compiled C++ (yes, you can also use C++).

BTW what is the reference in Python's grammar in the line

    # Commands for Kees Blom's railroad program

Is that like the diagrams in the old Jensen/Wirth Pascal book? I loved it that
the whole language was diagrammed on on a couple of pages.

Regards,
Bengt Richter



More information about the Python-list mailing list