Making a Python interpreter in 1024 bytes
Ranked #1 on Hacker News with 76 points and 28 comments.
To feel human, I write code by hand on the weekends.
My latest challenge? Make a Python interpreter in 512 1024 bytes of good ole C code. Oh, and no macro shenanigans or library tomfoolery.
I probably can't fit all of the Python language into an interpreter that is only 1024 bytes of code. So what can I fit that will look like Python?
This fizzbuzz program looks distinctly Python. It has the def , the colons, the indentations, and no parentheses for if statements. Looks like Python to me! Of course, I'll also have to add some additional limitations beyond just a subset of the syntax.
I've written many recursive descent parsers, so how different can this be? A subset of Python should be similar to the other languages I've implemented.
I started with the most basic code I could think of: 1 + 2