Hobby Notes written while learning

Source
to Machine.

A small hobby site where I share the notes I take while learning about compilers and programming languages. No profit motive. I'm not an expert; I'm learning too.

Compilation Pipeline

From Source Code to Machine Code

Follow a small Rust function through the compiler step by step. Click a stage to see its output.

sum.rsInput
fn sum(a: &[i32]) -> i32 { let mut s = 0; for x in a { s += x; } s}
tokensOutput
1:1keywordfn1:4identsum1:7punct(1:8identa1:9punct:1:11operator&1:12punct[1:13typei321:16punct]1:17punct)1:19operator->1:22typei321:26punct{2:5keywordlet2:9keywordmut2:13idents2:15operator=2:17number02:18punct; … 12 more tokens
1

Lexing: The source text is split into tokens such as keywords, identifiers, types, numbers and operators, each with its position.

Outputs are simplified for readability: release build, x86-64.

Open Source

Open Source and Helping Out

There is no public code repository yet. When the first small experiment is ready, it will go up on GitHub.

  • Compiler

    Reads source code, checks it and translates it to machine code. Usually split into a front end, middle end and back end.

    No repo yet
  • Language Server

    Gives the editor completion, go to definition and live error messages.

    No repo yet
  • Build System

    Tracks dependencies and rebuilds only what changed.

    No repo yet

How Can You Help?

For now, the easiest way is through the posts.

  1. 1
    Spot a Mistake

    If something in a post is wrong or unclear, let me know.

  2. 2
    Suggest a Source

    Share a book, paper or talk that helped you.

  3. 3
    Learn Together

    If you are learning too, send your notes or questions.

Write In