Python Forum

Full Version: how do i make a compiler?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
so yeeterday i watched this pyhton playlist https://www.youtube.com/watch?v=RjScQkED...TEt4gUrzeO and i think Im good enough now at programming so i thinked why I dont make a littel compiler?just to pracectis and see how my current programming skills are
do somebody knows how i can make a compilre? Please give a bit code

thanks in advance **biggrin** **biggrin** **biggrin**
I think the first step would be to decide how much you want to do. Do you want to write a parser? What do you want to compile your language to? Assembly? LLVM IR? A different language?

There are very good tools for parsing/lexing a language for you, to help cut some of the steps out. You'll probably want to use either PLY or Antlr.
http://dabeaz.com/ply/
https://www.antlr.org/

There's a great free book, that's still being written, that goes through the process of writing an interpreter: http://craftinginterpreters.com/
It uses Java, however, instead of Python.

The Original book, the Dragon book, is what was (...and might still be?) used to teach compiler theory in colleges such as MIT: https://www.amazon.com/dp/0321486811

Stack Overflow also tells me that this book is highly recommended: https://www.amazon.com/dp/0471976970
Aho's book was my bible.