From 7f3d23ac811966381ffc63d7e6055e7d5f3fb97f Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Tue, 1 Dec 2026 16:24:01 -0700 Subject: [PATCH] docs: explain what the lab folders contain and how to build it The README opened straight into the course handout with no map of the code. Adds the pipeline stage-to-file table, the lab-folder convention, and the build and run commands. --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a6464d..4fa39ba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,32 @@ # DECAF Compiler -Learning to build a compiler by implementing a compiler for the DECAF programming language. + +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. ## Tools - Flex