Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear, Member

I have some question to asking you:
How to build a compiler in C to converting to Java?

The condition of program is

1.input your C source code into Compiler
2.Converting and to show all of character appears along with which type, such as

Reserve Word, Token is ...

3. Output be show in Java code

By the way I've searching the related article in Google they' say it possible but not full option , I really to know your opinions How it can prove some part it working ?

Please, give me an advice

Email <Removed>
If you have some C source code to converting to Java Code

Thanks.
Posted
Updated 16-Jan-13 8:22am
v2
Comments
Sergey Alexandrovich Kryukov 16-Jan-13 14:15pm    
Why? I don't think it can make sense...
—SA
André Kraak 16-Jan-13 14:23pm    
You should not post your e-mail address on a public forum, unless you want to test your spam filter.
If someone comments on or answer your question you will be notified by an e-mail.

This is pretty difficult because C is of much lower level compared to Java. I don't think such work would make any sense. There are products which can be used to compile code written in different languages to Java machine. I used Ada; but it could also be C#, Object-oriented dialect of Pascal, Python, PHP, and more. Please see:
http://en.wikipedia.org/wiki/Java_virtual_machine#JVM_languages[^].

Adding C to this list can hardly do something good. The languages good to target JVM are usually object-oriented, or have close capabilities. You need something to represent classes, members of classes and related encapsulation. This is not about C.

And the term "converting to Java code" sound just ridiculous. What could you possibly mean by that? Listen for a good friendly advice: just forget it.

—SA
 
Share this answer
 
Comments
Espen Harlinn 16-Jan-13 16:00pm    
Good points - If OP really want interpreted C he can try interfacing with root/cint.
Sergey Alexandrovich Kryukov 16-Jan-13 16:09pm    
Thank you, Espen.
I have an idea on what you are talking about, but... ah, I can see you answer.
—SA
It could be made to work, but it's definitely nontrivial.

ROOT/CINT[^] will give you some idea about what's required to make something like this really work - but then I guess it will make more sense just to interface with CINT using JNI.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Jan-13 16:10pm    
Good point, if it makes sense at all; but it's a good reply, a 5.
—SA
Espen Harlinn 17-Jan-13 16:48pm    
Thank you, Sergey :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900