Interpreters-Compilers101

Experiments while reading the book Crafting Interpreters, building a toy compiler/interpreter in Rust

My compiler learnings/notes: Everything-About-Compilers

Break it down into beginner-friendly steps.

We’ll use a simple arithmetic language as an example.

enum Expr {
    Number(i32),
    Add(Box<Expr>, Box<Expr>),
    Subtract(Box<Expr>, Box<Expr>),
    Multiply(Box<Expr>, Box<Expr>),
    Divide(Box<Expr>, Box<Expr>),
}
enum Bytecode {
    Push(i32),
    Add,
    Subtract,
    Multiply,
    Divide,
}

There are also many great resources available if you want to learn more. The book “Crafting Interpreters” by Bob Nystrom is a great place to start, and it’s available for free online. There’s also the “Rust Programming Language” book by Steve Klabnik and Carol Nichols, which is a great resource for learning Rust.