I thought it would be fun to go outside of my comfort zone of web development topics and write about something completely different and new, something I have never written about before. So today, I'm going to show you how to implement a programming language!
The project will parse and execute programs written in a simple language I called
my (I know it's a lame name, but hey, it is "my" language). The implementation is going to be in Python, without any external dependencies. The
my language is simple enough to make this project reasonably short, but also complex enough to make it interesting. If you are only interested in the complete code, you can find it in this GitHub repository. If you want to learn, then read on!
In this first installment of this series, I'll show you how to build a very basic programming language that implements a print statement. Then in the second part I'll extend the language to support variables and mathematical expressions. The end goal is a programming language implementation that can execute programs such as this one:
a = 3
b = 4 + a * 2
print b + 1
Once you learn the techniques involved in bringing
my to life, you will be able to extend the language in any way you like and make it yours too. Sounds interesting? Let's get started!