My Bachelor thesis and the Peachpie project

Last year I created this blog with the intention of actually writing something here and there. (Un)fortunately I got quite busy with my bachelor thesis and a job that I landed thanks of it. Luckily I’ve written the thesis in English so in case you’re at least a bit interested in compilers feel free to check it out.

The thesis is about implementing a suppport for generators (methods with yields) within a PHP -> .NET compiler peachpie. While it might sound scary it’s really not. The peachpie compiler builds on proven Roslyn’s architecture and extending it was, in fact, way easier than I expected. The thesis mainly focues on lowering generators to more basic language (in this case CIL’s) blocks through semantic tree transformations. The full text is available here and the code created as part of it lives in the official project’s repository.


The goal of this thesis is to design and implement the support for generators within the Peachpie framework, a PHP to CIL compiler. Generators are the simplest form of methods that resume from the same state in which they returned earlier when called repeatedly.

The reference PHP interpreter Zend engine supports generators natively. Due to that fact that generators in PHP support a number of features that are not common in other languages. CIL, on the other hand, does not have a native support for generators. Therefore, languages built on top of CIL (e.g. C#, F#) have to implement them by other means, such as by rewriting the original generator methods into state machines.

In this thesis, we will design and implement the support for generators through semantic tree transformations. All this is handled with the intention of keeping the

Written by on