2.2 KiB
+++ title = "Course: Writing a Lisp-to-C Compiler in Rust" priority = 5 status = "done" ticket_type = "project" dependencies = ["e8da8b", "a93829", "3aeb62", "5835e9", "3dc36b", "685f5e", "a1a827", "b6c9ad", "a4c9f8", "d0b9f8", "6d40a7", "3e1250", "1eb794", "cbc6e3", "de82f1", "58b37a", "8fa47a", "1d16da"] +++
Course: Writing a Lisp-to-C Compiler in Rust
A complete self-guided interactive course teaching how to build a compiler from scratch in Rust using the nom parser-combinator library. The source language is MiniLisp — a minimal Lisp dialect. The compilation target is human-readable C.
Course file
edu/src/lisp-compiler.md
Section inventory
| § | Title | Ticket |
|---|---|---|
| 1 | Introduction: What We're Building | e8da8b |
| 2 | MiniLisp Language Specification | a93829 |
| 3 | Compiler Architecture: The Pipeline | 3aeb62 |
| 4 | Introduction to nom: Parser Combinators | 5835e9 |
| 5 | Setting Up the Project | 3dc36b |
| 6 | Recognizing Atoms: Integers, Booleans, Strings, Symbols | 685f5e |
| 7 | The Abstract Syntax Tree | a1a827 |
| 8 | Parsing Atoms with nom | b6c9ad |
| 9 | Parsing S-Expressions and Special Forms | a4c9f8 |
| 10 | Symbol Tables and Scope | d0b9f8 |
| 11 | Checking Special Forms | 6d40a7 |
| 12 | The C Runtime Preamble | 3e1250 |
| 13 | Generating C: Atoms and Expressions | 1eb794 |
| 14 | Generating C: Definitions and Functions | cbc6e3 |
| 15 | Generating C: Control Flow and Sequencing | de82f1 |
| 16 | The Compilation Pipeline | 58b37a |
| 17 | Testing the Compiler | 8fa47a |
| 18 | What's Next: Extensions and Further Reading | 1d16da |
MiniLisp feature set
- Types: integers (
int64_t), booleans (#t/#f), strings (const char*) - Special forms:
define,lambda,if,let,begin - Built-in operators:
+,-,*,/,=,<,>,<=,>=,not - Built-in functions:
display,newline,error - Comments:
;to end of line
Explicitly out of scope
Closures, tail-call optimisation, pairs/lists, garbage collection, macros, variadic functions, floating-point. Each is discussed as a potential extension in §18.
Definition of done
All 18 section tickets are done and mdbook build succeeds with no 🚧 stubs remaining in the output.