# DECAF Compiler > **Note:** the "What's in here" and "Build and run" sections below were written by an AI assistant (Particle-1) on > the maintainer's behalf on 2026-12-01, by reading the lab folders. The course handout and the 2021 code are the > maintainer's own work; corrections welcome. Learning to build a compiler by implementing a compiler for the DECAF programming language. ## What's in here A working compiler for DECAF (a trimmed-down typed C-like language), built stage by stage over a semester of CS370: | Stage | Where | | --- | --- | | Lexical analysis — a Flex specification turning source into tokens | `9LAB/lab9.l` | | Syntax analysis — a Bison grammar producing the parse tree | `9LAB/lab9.y` | | Semantic analysis — AST construction, type checks, scopes | `9LAB/ast.c`, `9LAB/symtable.c` | | Code generation — MIPS assembly from the AST | `9LAB/emit.c` | The numbered folders (`1LAB` … `9LAB`, plus homework and an exam) are the increments the course was taught in; each carries its own README with the assignment and sample output, so the folder itself is the progress log. `9LAB` is the finished pipeline. ## Build and run ```bash cd 9LAB make clean && make # gcc + flex + bison -> ./lab9 ./lab9 < test1.decaf # writes MIPS assembly to stdout ``` Inputs and the assembly produced for them sit side by side (`test1.decaf` / `test1.asm`), which makes the tests diffable without a harness. ## Licence MIT.