matcha-compiler is the current reference compiler for Matcha.
It is still early in development, but it already reads .mt source files, parses and analyzes them, emits LLVM IR, and links that IR together with the Matcha runtime into a native executable. The runtime currently uses Boehm GC (bdw-gc), and the final native link step is performed through clang.
Warning
This compiler is still experimental. Matcha is currently best understood as a fast-moving v0.1.1 hobby language project rather than a stable platform.
This directory contains:
- the Matcha CLI
- the compiler frontend and semantic analysis pipeline
- LLVM IR codegen
- native build and run orchestration
- the Matcha runtime library
- unit and end-to-end tests
- example Matcha programs
The current compiler supports a practical core language, including:
valandvarint,boolean, andstring- arrays with indexing,
append, andlength - structures with fields, methods, and type functions
if,while,for,loop, andmatch- built-ins such as
printInt,printString,readFile,readLine, andgetArguments
For the most accurate view of what works today, use the examples in examples/ and the tests in tests/e2e/.
On macOS:
brew tap mario-nowak/tap
brew install mario-nowak/tap/matcha-lang
matcha --helpThen try an example program from this repository:
git clone https://github.com/mario-nowak/matcha.git
cd matcha/matcha-compiler
matcha run examples/learning-matcha.mtIf clang is not available yet, install Xcode Command Line Tools:
xcode-select --installFrom matcha-compiler/ on macOS:
brew install mise llvm@20 bdw-gc
mise trust
mise install
mise run build
./zig-out/bin/matcha run examples/learning-matcha.mtThe documented source-build setup path currently targets macOS and uses Homebrew plus mise.
brew install mise llvm@20 bdw-gccd matcha-compiler
mise trustmise installThat gives you:
zig 0.15.1- Homebrew LLVM 20 on
PATH clangand LLVM tools for linking and IR workflowsbdw-gcfor the runtime and final native binary
If you prefer release artifacts instead of Homebrew, download the latest compiler release from GitHub and extract it so that the bundled layout stays intact:
bin/matcha
lib/libmatcha_runtime.a
matcha also expects:
clangonPATHbdw-gcinstalled through Homebrew
After extraction, verify the install with:
matcha --helpFrom matcha-compiler/:
mise run buildEquivalent raw Zig command:
zig buildThe built compiler binary is placed at:
zig-out/bin/matcha
Show CLI help:
./zig-out/bin/matcha --helpEmit LLVM IR:
./zig-out/bin/matcha emit examples/learning-matcha.mtBy default, this writes:
examples/learning-matcha-llvm-codegen.ll
Build a native binary:
./zig-out/bin/matcha build examples/learning-matcha.mt
./examples/learning-matchaBy default, build writes a binary next to the source file using the source stem as the output path.
Build to an explicit output path:
./zig-out/bin/matcha build examples/learning-matcha.mt --output ./tmp/learning-matcha
./tmp/learning-matchaCompile and run in one step:
./zig-out/bin/matcha run examples/learning-matcha.mtPass program arguments through run:
./zig-out/bin/matcha run examples/customer-import-audit.mt -- ./sample-input.txtUsing mise tasks:
mise run check # compile-check the project
mise run build # build the compiler and runtime
mise run test-compiler # run Zig unit/integration tests wired through build.zig
mise run e2e # run end-to-end tests
mise run test # run compiler tests and e2e tests
mise run verify # lint + build + compiler tests + e2e
mise run checkfix # format, then run full verification
mise run build-compiler # optimized ReleaseFast buildRaw Zig equivalents:
zig build check
zig build
zig fmt --check .
zig build test --summary all
zig test tests/e2e/tests.zigThe test suite covers both internal compiler behavior and real compile-and-run workflows.
zig build test --summary allruns unit and integration tests throughbuild.zigzig test tests/e2e/tests.zigruns end-to-end tests against real Matcha source programsmise run testruns the full local test workflowmise run verifyruns the same local verification sequence expected by CI
Run end-to-end tests with:
mise run e2eor:
zig test tests/e2e/tests.zigAt a high level:
src/cli/parses commands such asemit,build, andrunsrc/compiler/lexes, parses, performs semantic analysis, and emits LLVM IRsrc/toolchain/takes the emitted IR and performs the native link/run workflowruntime/provides the runtime functions linked into compiled programs- the final link step combines:
- emitted LLVM IR
- static
libmatcha_runtime.a bdw-gc
- the result is a native executable
Command behavior:
matcha emit→ compiler only, writes LLVM IR to diskmatcha build→ compiler plus native link step, produces a binarymatcha run→ compiler plus native link step plus process execution, using temporary artifacts
matcha-compiler/
├── src/
│ ├── cli/ # command parsing and CLI execution
│ ├── compiler/ # lexer, parser, semantic analysis, LLVM IR codegen
│ └── toolchain/ # native build/run orchestration and linking
├── runtime/ # Matcha runtime linked into compiled programs
├── tests/
│ └── e2e/ # end-to-end tests over real Matcha programs
├── examples/ # sample Matcha source programs
├── build.zig # Zig build graph
└── .mise.toml # local toolchain and task definitions
Example programs live in examples/:
learning-matcha.mt, which gives a guided tour of the currently implemented languageaoc-2024-01.mt, which shows Advent of Code-style parsing and list processingcustomer-import-audit.mt, which offers a more idiomatic example with structures, normalization, and decision logic
If you want one file to read first, start with examples/learning-matcha.mt.
- The documented setup currently targets macOS.
- Native linking expects Homebrew-installed
bdw-gc. - The final native link step currently shells out to
clang.