Python Forum
how do i make a compiler? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how do i make a compiler? (/thread-14428.html)



how do i make a compiler? - lol - Nov-29-2018

so yeeterday i watched this pyhton playlist https://www.youtube.com/watch?v=RjScQkED_C8&list=PLjm6-HXaB62IKT94yi6kc2JTEt4gUrzeO 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**


RE: how do i make a compiler? - nilamo - Nov-29-2018

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


RE: how do i make a compiler? - Larz60+ - Nov-29-2018

Aho's book was my bible.