Meet pypa, libpypa
For quite a while, I have been playing with the thought of writing a parser for a programming language. I have never written one before and therefore I somehow had to scratch an itch in that regards.
That itch however was never that much disturbing that I would just go ahead and write an arbitary programming language parser.
To be honest, back in 2004 I have been ‘contributing’ to a language parser project, namely OpenC++ but that was a massive project (at least for my perception at that time). I was overwhelmed by it and additionally very new to programming in general so I did not really do much on that project. At the same time the OpenC++ project also lost its drive, unfortunately, what eventually led to the fact that I let go of it and followed other interests.
Fast-forward 10 years. It’s 2014 and the pyston project by dropbox was announced. It took a while until I had a look at it. However once I did have a look at it I realized that this project is quite interessting and has a very interessting goal. Making Python Just-In-Time compiled using LLVM.
That sounds like a great idea. But there’s a caveat, pyston is using CPython to parse the python files. It dumps the Abstract Syntax Tree (AST) to the standard output in a custom binary format and pyston reads it from there to generate it’s own AST.
Now however the pyston project has expressed the interest in a parser for Python. I really love C++ and Python is still my language of choice for certain things, and I do earn my money by writing/extending/fixing Python applications.
So the idea was born in my head: Let’s start writing a Python parser library in C++.
So I went for it:
Internet, meet libpypa - http://github.com/vinzenz/libpypa