Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C Java
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
Posted 16-Jan-13 9:07am
Edited 16-Jan-13 9:22am
Sergey Alexandrovich Kryukov at 16-Jan-13 14:15pm
Why? I don't think it can make sense...
André Kraak at 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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^].
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.
Espen Harlinn at 16-Jan-13 16:00pm
Good points - If OP really want interpreted C he can try interfacing with root/cint.
Sergey Alexandrovich Kryukov at 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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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
Sergey Alexandrovich Kryukov at 16-Jan-13 16:10pm
Good point, if it makes sense at all; but it's a good reply, a 5.
Espen Harlinn at 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)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 BillWoodruff 85
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310

Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100