The stages of t27c
You will learn
The order of the compiler stages and what each one produced for the lesson spec.
The lexer cuts the text into tokens. The parser builds a tree of nodes. The type checker reports errors and warnings without stopping the backends. HIR is the hardware view that the verilog_hir backend is written from; the other backends read the parser's tree. The table shows the counts each stage gave for the lesson spec, measured with the compiler on this site.
Try it
Open the t27c stages widget, paste the lesson spec, and match its counts with the table.

What each stage of the t27c compiler produced for one small spec: bytes, tokens, tree, type check, HIR and backends. Lesson 23 of the t27 basics course.
specs/basics/23_stages_of_t27c.t27
// SPDX-License-Identifier: Apache-2.0
; t27 basics, lesson 23: The stages of t27c.
; Bytes, tokens, a tree, a type check, HIR and code: how t27c reads a spec.
module basics_23_stages_of_t27c;
pub const WIDTH : u8 = 8;
pub fn add(a: u8, b: u8) -> u8 {
return a + b;
}
test width_is_a_byte {
assert WIDTH == 8;
}
All lessons
Module 1 · A spec file
What a .t27 file holds: a module line, prose lines and comments.
Module 2 · Values and types
Constants, the width of a whole number, and true, false and text.
Module 3 · Arrays, trits and expressions
Lists of values, the three values of a trit, and what operators compute.
Module 4 · Tests and functions
A test block, several small tests in one spec, and a function with typed inputs.
Module 5 · Inside a function
Names with let and var, choices with if and switch, and loops.
Module 6 · Visibility and your own types
What pub shares with other modules, and the structs and enums you declare.
Module 7 · Modules, rules and gen-ts
Reading another module, stating a rule that always holds, and a spec turned into TypeScript.
Module 8 · The compiler and tri
The backends t27c writes, the stages it reads a spec in, and the tri command.
Module 9 · Errors, a program, what next
Reading a compiler error, one small complete program, and the course to take next.