C++ – How to Convert an Interpreter to a Compiler

ccompiler

First off, I know this is a question asked by MANY other programmers before me. But I couldn't find any usable resource that could help me.

Well, I'm creating an programming language called "Light" the syntax is comparable to python but it has a strict object-orientated concept.

I have made an interpreter ( in C++ ) for this language yet, my problem is how to turn this into an executable. ( Or simply: how do I make a compiler ? )

Thanks for your attention

P.S.: I've found some links to a very old tutorial but it is in Pascal…

EDIT:
Well, well. Now I have found a suitable tutorial for C++.
About the project: There have been some changes. Now the language is called "Q." ( kju Dot ).

Best Answer

The first couple of steps lexing/parsing (and analysis, depending on how that's structured) can be the same. But you will need to convert your representation to a code-generating representation. Typically LLVM is used for hobbyists as it is pretty much the only remotely decent free code-generating library around.