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.
This commit is contained in:
Ziad Arafat committed 2026-12-01 16:24:01 -07:00
1 parent 2f27179a92
commit 7f3d23ac81
1 file changed
+28 -1
+28 -1
View File
@@ -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