Question:
what techniques can I use to translate a source code to another source code?
sigangnoypi31
2008-07-03 07:20:17 UTC
translating one source code to another source code is my senior year thesis topic. I'm looking for an executable technique to accomplish this.

e.g. C++ -> ??? -> Java

???-is the method or technique I need to use to convert the source code.

Thanks.Please help me.It's urgent.
Four answers:
DogmaBites
2008-07-03 07:36:46 UTC
It's July. You haven't worked on this yet? Luckily for you, C++ and Java are relatively close. Other languages would be more difficult.



In short, what you are trying to do is write a compiler, but one that output code in another high level language vs. machine code. This is quite a big job. However, you might be able to take a number of shortcuts. For example, you could skip the C++ preprocessor (i.e. macros).



What you have to do is look at the statements allowed in the source language and see how they translate to the other. How do basic types compare? How do you declare classes and functions?



You will have to write a parser for the source language. This is probably the most difficult part. Maybe you can restrict the number of language elements at first to make the problem tractable.



In the end, it is possible. since both language are compilable to machine(-ish) languages, they can be translated in theory. In practice, because of differences in system libraries there will be a lot of rote work.



You can't expect YA to come up with a major part of your thesis. You are out of the range by many orders of magnitude.
niederberger
2017-01-03 16:09:53 UTC
Decompilers paintings, as much as a element. If the unique had any form of autoboxing, that's no longer pondered because of the fact ArrayList1e145bb839d77fcc8486b79e9c73bd0 al = new ArrayList1e145bb839d77fcc8486b79e9c73bd0() the Thing is erased for the time of compiling. The autoboxing isn't a great factor whilst they used the API gadgets, yet whilst it incredibly is a few type merchandise, you're transforming into some subject reassembling the code. additionally, you will get very ordinary names for the variables and concepts, eg inner maximum int method5555( String arg1, double arg2) { // } you are able to no longer recuperate the javadoc do no longer get hold of a decompiler. some utility companies declare they more suitable OpenSource classes and made them proprietary.
The Don
2008-07-03 07:26:51 UTC
This is not a simple task.Java lacks the arbitrary pointer arithmetic of c++.

However there are automatic translation tools available. But commercially we may use these tools, but there is always modifications that are required...its a painful process.



Also if this is your final year project, id recommend you always keep in mind, even if you dont acheive a software that can do this, or find a perfect technique, stress the importance of why your doing it and why what you have done is infact important and helpful to others whom wish to attempt the same in the future.
2008-07-03 08:10:07 UTC
Know both languages and do the conversion by hand and brain. Seriously. Until there are workable decompilers, it's the only way.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...