C source viewer/mapper?

Simon Burton simonb at webone.com.au
Mon Dec 23 00:21:19 EST 2002


On Mon, 23 Dec 2002 03:57:19 +0000, Bengt Richter wrote:

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

  No, i'm writing in the style of a "recursive descent" parser;
rather than bringing the grammar to the fore, the recursive parsing
mimics the grammar in the (hand coded) control flow. Also i've heard
that these are faster parsers than the grammar based ones.
  My sarting point has been Peter Van Der Linden, his book "Expert C
programming", where he explains how to parse c declarations.
  I have also been working with an ANSI c grammar (for bison) i found somewhere,
it's been helpful, but the grammar allows a lot of weird stuff, like "int
f()()()();"

> 
> 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

Some interesting points you raise,

Simon Burton
http://arrowtheory.com




More information about the Python-list mailing list