// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/basics-stages-of-t27c.t27 -- the infographic of lesson 23 of the t27 basics course (specs/course/t27-basics.t27) ; Source of truth for public/widgets/basics-stages-of-t27c/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles ; this file, checks its constants, evaluates the tests below and writes the page. tool.js is one import of ; ../infographic.js, which draws SAY_TABLE_* as a real and SAY_FLOW_* as an SVG diagram with a ; , black and white, and holds no words of its own. ASCII only (L3), English only (LANG-EN). ; The lesson spec it illustrates: public/t27/files/specs/basics/23_stages_of_t27c.t27. ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_basics_stages_of_t27c; pub const KIND : str = "widget-tool"; pub const ID : str = "basics-stages-of-t27c"; pub const TITLE : str = "t27 basics 23: the stages of t27c, counted"; pub const DESCRIPTION : str = "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."; pub const IMAGE_ALT : str = "A black and white diagram of the stages of t27c in order, source bytes, lexer tokens, parser tree, type check, HIR and backends, with a table of the count each stage gave for the lesson spec."; pub const HOOK : str = "A small t27 spec, stage by stage: bytes, tokens, tree, type check, HIR, 7 backends."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [2]str = ["The lesson spec public/t27/files/specs/basics/23_stages_of_t27c.t27, compiled clean on 7 backends by public/t27/t27_compiler.wasm, whose tests pass in the site test runner", "Compiler verdicts, error lines, code and counts quoted on this page are what the same wasm answered in node 22 when the course was authored; words without a run behind them are said to be read, not run"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; ; --- The table ----------------------------------------------------------------------------- pub const SAY_TABLE_CAPTION : str = "Stages on the lesson spec"; pub const SAY_TABLE_HEAD : [2]str = ["Stage", "Result"]; pub const SAY_TABLE_CELLS : [12]str = ["Source", "324 bytes, 15 lines", "Lexer", "41 tokens", "Parser", "3 top-level nodes", "Type check", "0 errors, 0 warnings", "HIR", "built, 51 lines", "Backends", "7 of 7 wrote code"]; pub const K_TABLE_COLS : u8 = 2; pub const K_TABLE_ROWS : u8 = 6; pub const K_TABLE_CELLS : u16 = 12; ; --- The diagram and the note ---------------------------------------------------------------- pub const SAY_FLOW_TITLE : str = "The stages of t27c"; pub const SAY_FLOW_STEPS : [6]str = ["Source bytes", "Lexer: tokens", "Parser: a tree", "Type check: a report", "HIR: the hardware view", "Backends: code"]; pub const K_FLOW_STEPS : u8 = 6; pub const SAY_NOTE : str = "Counts are what t27_compiler.wasm answered when this page was authored."; test the_cells_fill_whole_rows { assert K_TABLE_ROWS * K_TABLE_COLS == K_TABLE_CELLS; } test the_table_has_a_body { assert K_TABLE_ROWS > 0; assert K_TABLE_COLS > 0; } test the_diagram_has_every_step { assert K_FLOW_STEPS == 6; assert K_FLOW_STEPS > 1; }