Compiler overview
import { CardGrid, LinkCard, FileTree, Aside } from ‘@astrojs/starlight/components’;
The Sysl compiler is written in Scala 3. It runs on the JVM, on Node via Scala.js, and as a native binary via Scala Native — the three cross-platform modules share almost all their code. The full compiler is around 15,000 lines.
Pipeline
Section titled “Pipeline”Multi-module orchestration
Section titled “Multi-module orchestration”SyslDriver.scala coordinates compilation across files:
- Discover sources (
*.sysland*.lsysl) passed on the command line or found in a directory. - Pre-parse to extract module declarations and import lists.
- Topologically sort the module graph — circular imports are an error.
- Compile in dependency order. Each module’s public symbols are cached in a
.smetafile; downstream modules read the cache instead of re-parsing. - Emit once all modules have been analysed. The driver invokes the selected backend per module and links the outputs (for TRISC, via the same linker TRISC assembly uses).
.smeta files also carry #pure, #deprecated, and trait-impl information across module
boundaries so the analyser doesn’t need to re-read a module’s full source to check a call
site.
Conditional compilation
Section titled “Conditional compilation”#if / #else / #endif blocks are resolved in the driver, before the per-file analyser
runs. The driver maintains a set of defined symbols (TARGET, DEBUG, BARE_METAL, …),
strips the inactive branches, and passes the remaining source to the parser.
sysl-cli — the command-line front-end
Section titled “sysl-cli — the command-line front-end”sysl-cli/ wraps the compiler with commands:
| Command | What it does |
|---|---|
sysl run <file> | Compile and run via the interpreter |
sysl compile <file> | Produce .tof, .asm, or .ll output |
sysl test <file-or-dir> | Discover and run #test-annotated functions |
sysl doc <file-or-dir> | Render .lsysl prose to HTML |
The test suite in sysl/src/test/scala/ is the behavioural contract. It covers parser,
analyser, interpreter, and both codegens. Over 500 focused tests across 40+ files, organised
by feature area (generics, traits, tagged unions, contracts, closures, modules, …).
See Testing Strategy for layout and workflow.