Is there any python library that parse c++ source code statically
Francesco Bochicchio
bieffe62 at gmail.com
Sun Mar 13 05:37:27 EDT 2011
On 13 Mar, 10:14, kuangye <kuangye19840... at gmail.com> wrote:
> Hi, all. I need to generate other programming language source code
> from C++ source code for a project. To achieve this, the first step is
> to "understand" the c++ source code at least in formally. Thus is
> there any library to parse the C++ source code statically. So I can
> developer on this library.
>
> Since the C++ source code is rather simple and regular. I think i can
> generate other language representation from C++ source code.
The problem is that C++ is a beast of a language and is not easy to
find full parsers for it.
I've never done it, but sometime I researched possible ways to do it.
The best idea I could come with
is doing it in 2 steps:
- using gcc-xml ( http://www.gccxml.org/HTML/Index.html ) to generate
an xml representation of the code
- using one of the many xml library for python to read the xml
equivalent of the code and then generate the equivalent
code in other languages ( where you could use a template engine,
but I found that the python built-in string
formatting libraries are quite up to the task ).
HTH
Ciao
---
FB
More information about the Python-list
mailing list