At AdGear, the developers typically end their week at “Friday Not Friday”, a team activity from 4pm to 5pm. One person gives a presentation on any technical subject while the others listen and sip a beer to wind down before the week-end.
Last week, I gave a demonstration that I called “Speedrunning a Compiler”. I wanted to show my colleagues the basics of writing a compiler, and I thought it would be more instructive if they saw code rather than an abstract flowchart. Thus, I wrote a compiler for a very small language that I call “Minilang”. We went over the classic phases of a compiler: scanner, parser, typechecker, and code generator. I used Python as my implementation language; the code I wrote was not pretty and abused Python’s flexibility (mutation galore, dynamic typing, using strings and dicts instead of objects) and I generated MIPS assembly.
The resulting program is available on Github: https://github.com/gnuvince/fnf-vfoley/blob/master/compiler/compiler.py
Thanks to a couple practice runs during the week and some copy-pasting from my completed example, I was able to finish in about 50 minutes and hopefully to enlighten my colleagues a little bit.