C++ parser in Java

P

PaulR

Hi,

can anyone recommend a reliable C++ parser for Java?

I have a C++ project with around 300 (very similar) classes which I
want to migrate to Java. It would be a big help to be able to parse the
original files and extract key information from them. Especially struct
info, variable and method names, comments etc and then create Java
skeletons.

I see that Eclipse has a C++ project. Is the parser accessible?

Any ideas?

Thanks

Paul Ramsden
 
H

Hal Rosser

Try some of the modeling software.
Argo and Poseidon can convert Java code to UML and back
Some may be able to do the same with C++ AND Java
 
B

bugbear

PaulR said:
Hi,

can anyone recommend a reliable C++ parser for Java?

I have a C++ project with around 300 (very similar) classes which I
want to migrate to Java. It would be a big help to be able to parse the
original files and extract key information from them. Especially struct
info, variable and method names, comments etc and then create Java
skeletons.

Do you want a C++ parser coded in java, a parser
that will generate java from C++, and if the latter
do you want it implemented in C++, java or other?

Since Java is so different from C++, I suspect a simple
perl (or similar) HACK would server, especially since the
C++ can be assumed to follow (your) textual conventions.

In any case, this may be helpful:
http://www.parashift.com/c++-faq-lite/compiler-dependencies.html#faq-38.11

BugBear
 
B

Betty

bugbear said:
Do you want a C++ parser coded in java, a parser
that will generate java from C++, and if the latter
do you want it implemented in C++, java or other?

Since Java is so different from C++, I suspect a simple
perl (or similar) HACK would server, especially since the
C++ can be assumed to follow (your) textual conventions.

In any case, this may be helpful:
http://www.parashift.com/c++-faq-lite/compiler-dependencies.html#faq-38.11

BugBear

Try this, first compile the C++ program to gen an object file.
Then use a decompiler to get the source back. This will get rid
of all the preprocessor, comments, etc. and put the source into
a regular style that should be the same for all your c++ programs.
This should make it easier to write a program to convert from c++
to java. Maybe even you can play with "lex" (not the bad guy
on superman.)
 
P

PaulR

Thanks Betty. That's a useful idea, but I would like to migrate the
comments as well.

Ideally, I would like to get some kind of a tree structure which I can
navigate through.

e.g. get all private methods, get member variables etc.

Paul
 
M

Michiel Konstapel

Thanks Betty. That's a useful idea, but I would like to migrate the
comments as well.

Ideally, I would like to get some kind of a tree structure which I can
navigate through.

e.g. get all private methods, get member variables etc.

Paul

There may be a C++ grammar for JavaCC, try googling for that.
Michiel
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top