Why you should write a port of SLANGFOR.NET in any language

Have you ever wondered about how write a compiler? and still you don’t have any idea about it? If your answer is ‘Yes’ this article is for you.
I was also very curious about it and feared reading Dragon books :P. But i met a guy called Praseed Pai(http://praseedp.blogspot.com) who just told me that ‘Compiler is just another program’ :). He started a project in 2010 called SLANGFOR.net which is hosted at codeplex(http://slangfordotnet.codeplex.com). This project is an attempt to teach compiler construction by writing a small compiler. It is written in C#, and documented well to understand. Documentation is orgonized in 7 steps. Initial steps are dealing with arithmetic expressions and following steps play with variable declaration, assignment operations, control structures like conditions and loops and finally function. It will not help you to understand big theories behind compiler construction and all. but i swear at least you will get a confidence to write your own DSL.

Recently i ported SLANGFOR.net to Python. only interpreter part, still need to write a backend. project is hosted on github (https://github.com/faisalp4p/slang-python)
I have leaned lot of things by doing this. such as Lexical Analysis, AST, Recursive Descent Parsing, DSL. I took only six days to port it. may be because of the simplicity of python. After that we discussed about it and he gave some more ideas like how we can change it to support dictionaries and Object Oriented programming.

So i recommend you to port SLANGFOR.net to any language if you want to learn
some lessons in compiler construction.

Leave a comment