Storey 02 / 05 / The Pagoda
Languages
A programming language is how a person tells a machine what to do. A compiler turns that text into the instructions a processor runs.
For my compilers module I wrote one for MiniC, a small part of C, in C++. Most days I write Python and TypeScript. I use Java, SQL and Bash where the job needs them.
Writing a compiler changed how I read code. I see each line as something that has to be split into tokens, checked against a grammar and turned into steps.
The tower
Tools 8
- C++The language the MiniC compiler is written in, from the lexer to code generation.Mini C Compiler →
- FlexLexing: cutting the compiler's source text into tokens such as names, numbers and keywords.Mini C Compiler →
- LLVM IRWhat the compiler writes out. LLVM's llc and clang then turn it into an x86-64 program.Mini C Compiler →
- PythonThe football video pipeline, the pathology slide pipeline and the finance app's backend.Football Intelligence →
- TypeScriptThe React screens of the finance app and the football dashboard.Finance Agent →
- JavaA gig booking system on a PostgreSQL database, a robot that learns a maze, and a film catalogue built on its own data structures.
- SQLThe tables, triggers and views of the gig booking system.
- BashThe compiler's test runners, and the scripts that check and merge each lane of the agent team.Mini C Compiler →
Notes from this storey
A grammar the parser can follow
A parser that reads from the top down cannot use a rule that starts with itself, such as an expression that begins with an expression. It would go round forever.
Checking against clang
To debug my code generator, I had clang write out its own LLVM IR for the same program and compared the two.
Standing on this storey
Project / 2025
Mini C Compiler
A compiler is the program that turns code a person writes into instructions a computer runs.
The code the compiler writes out is a fifth smaller once it drops work that can be done early or never runs.
Read the chapter