SMAL (State Machine Abstraction Language) is a compact, human‑readable YAML DSL for defining fully functional state machines that are:
- Simple — easy to write, easy to read
- Robust — validated, structured, and type‑safe
- Debuggable — designed for real firmware workflows
A .smal file describes your entire state machine — states, events, transitions, commands, messages, and error handling — in a clean, declarative format. From that single source of truth, SMAL can generate:
- C, C++, and Rust firmware code
- A complete SVG state machine diagram
- Debug structures for introspection and tooling
- Human-readable reports for developers and QA
SMAL is built for embedded systems, audio devices, wearables, robotics, and any environment where clarity, determinism, and debuggability matter.
SMAL also ships an interactive REPL CLI (smal) for working with your state machines directly from the terminal — load and validate .smal files, generate code and diagrams on demand, and connect to a live device to send messages and run scripted command sequences against it.
Define states, events, transitions, actions, etc. in a clean, expressive format.
Generate firmware-ready code in C. C++ and Rust planned for future release.
Produce a polished, auto‑layout state machine diagram directly from your .smal file.
SMAL includes a structured debug layout that maps cleanly to firmware and tooling.
A simple interface for defining how to communicate with your embedded device is provided so you can add comms directly to the REPL!
Want to write structured sequences of messages that you can send with a single command? SMAL provides that with an easy, YAML-based script structure (*.smalscr) that works seamlessly with your messaging paradigm of choice.
Add custom generators, validators, or analysis tools.
pip install smal-langOr, using uv:
uv tool install smal-lang # install the `smal` CLI globally
uv add smal-lang # or add it as a project dependencyTry it with one of the bundled examples in src/examples:
smal
smal> machine load src/examples/simple/simple.smal
smal> diagram ./outThis loads the machine and renders out/simple_state_machine_diagram.svg. Run code generate <template> -o <output_dir> to generate firmware code from the same file.
MIT — see LICENSE. See CHANGELOG.md for release history.