Is there any python library that parse c++ source code statically

K

kuangye

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

Francesco Bochicchio

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
 
S

Stefan Behnel

Francesco Bochicchio, 13.03.2011 10:37:
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 ).

I also heard that clang is supposed to the quite useful for this kind of
undertaking.

Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top