Kaleidoscope Tutorial
This tutorial teaches pliron by building a small Kaleidoscope-like language and a compiler pipeline for it.
The tutorial takes you through the following chapters:
- Parse source text (in the Kaleidoscope language) into an AST.
- Define a new Kaleidoscope dialect for the language.
- Lower AST nodes into the Kaleidoscope dialect IR.
- Lower the Kaleidoscope dialect into LLVM dialect IR.
- Use LLVM-JIT to compile and run the resulting LLVM IR.
Prerequisites
- Comfortable with Rust (did you read the Rust book?).
- Familiarity with basic compiler terms (AST, IR, lowering).
How to use this tutorial
- Read a chapter.
- Try out the example tests.
- Modify it (as desired) or add new tests and re-run.
- Move to the next chapter.
Each chapter mentions runnable example tests that you can execute. Typically, you can run them with:
cargo test --example kaleidoscope -- <test_name> --show-output
For a chapter-to-test map, see the Examples and Tests Index.
Build and view the tutorial offline (optional):
mdbook build kaleidoscope
mdbook serve kaleidoscope