I’m looking to make a small compiler for personal/friend usage. Just some basic input output console functions. And all that other stuff like Strings, ints, floats, chars, bools and and so on. But I want to do this in java. I know what your going to say, I should use something practical and fast, like C. But I want a little OOP in it too. Now, you must be thinking, C++. There is one issue I have with that. It’s finished programs are .exe files. Now I know that you don’t need anything installed to run .exe, and to run a .jar, the file I want it to be, you need the JVM installed. But I have some friends on Apple computers, and I don’t have an Apple, so I couldn’t have another version written in Obj-c for those people. You can get the JVM on Apple, and even linux if you want, and this would be a cross platform. I know it would be slower, but its just a small language, and the difference is such a small amount, compapred to things like the first calcuator, that took minutes. Any and all help would be apricciated, unless the help is something like “Get a life” or “Learn C”. I’m best at Java, and love the cross platform, so if you suggest anything that is not java, I’ll be very annoyed. Thanks!
EDIT: Not to many people can see the question I’m asking, so here it is again. I want to know how to make A compiler in java. That’s it.
Have a look at these tutorial(s)/link(s):
If you want to create a compiler to compile your own language you’ll have to be doing more work then creating a compiler. You need language syntax, heaps, stacks, mnemonics, op-codes, debuggers etc and lastly the compiler.
If you however want to create your own custom compiler for the Java language see:
should do it.
You might look at the Byte Code Engineering Library (BCEL ) for some inspiration as well as Findbugs (it has to read/understand class files).
EDIT:
Here is another similar question with some great answers: Learning to write a compiler