Decaf Compiler
Simon Fraser University (SFU) | CMPT 379: Principles of Compiler Design | Summer 2025 | Taught by: Dr. Anoop Sarkar

Simon Fraser University (SFU) | CMPT 379: Principles of Compiler Design | Summer 2025 | Taught by: Dr. Anoop Sarkar
Decaf is a simple programming language introduced in CMPT 379 at Simon Fraser University (SFU) in Summer 2025, taught by Dr. Anoop Sarkar (course website). In the course, students learn how to build a working compiler that follows the official Decaf specification: Decaf Language Spec.
At a high level, the Decaf compiler reads code written by the user, breaks it into tokens using Flex (for lexical analysis), and then parses and interprets the structure using Bison. After that, it generates an intermediate representation (IR) and compiles it into binary code using LLVM. This binary can be run on different operating systems, thanks to LLVM’s cross-platform support.
Our group successfully built the Decaf compiler. For the demo, I integrated the compiler into a simple React web app. However, hosting it came with some challenges. Vercel, the platform I used for the deployment, does not support running custom binaries because it isn’t a full virtual server (see Vercel limitations). To solve this, I deployed the compiler as a separate backend service using Docker on Render.com. While Render has a cold-start delay (especially on free plans), it worked well for my needs.
Here is an overview of Decaf compiler:
Here is a React Decaf Editor (thanks to MDX!)
To build or rebuild the Decaf compiler yourself, please follow the setup/installation guide on GitHub.
Note: the editor does not have any security built in, and it is being hosted on a standalone server. In case you ended up breaking it, I'll have to restart/rebuild the container. Please don't do that! Thank you!