C parsing fun

Szabolcs Nagy nszabolcs at gmail.com
Mon Feb 5 08:00:35 EST 2007


> based on concepts my boss had. To do this I needed to represent C++
> code structure in Python somehow. I read the docs for Yapps, pyparsing
> and other stuff like those, then I came up with a very simple idea. I
> realized that bracketed code is almost like a Python list, except I
> have to replace curly brackets with squared ones and surround the
> remaining stuff with quotes. This process invokes no recursion or node

yes that's a nice solution
sometimes it's not enough though (won't work on code obfuscated with
macros)

anyway if you need something more sophisticated then i'd recommend
gccxml or it's python binding:

http://www.language-binding.net/pygccxml/pygccxml.html




More information about the Python-list mailing list