Sane is a small programming language that compiles to 8-bit Brainfuck.
saneccompiles Sane source (.sn) to Brainfuck (.bf).saneiruns and debugs Brainfuck programs.
Sane supports byte and void functions through the basic-block IR of the
experimental pc backend. The compiler automatically uses the structured
backend for programs without functions and the PC backend for programs with
functions. The language also supports compile-time byte constants and inferred
array declarations, plus compile-time checked formatted output.
After placing the release binaries on PATH, compile and run the AES-inspired
example:
sanec examples/toy_aes_round.sn -o toy.bf
printf ABCDEFGHIJKLMNOP | sanei toy.bfExpected output:
toy-aes:ED958E73EFAD3E04336822CC237B065A ok
Compile a function program with the PC backend:
sanec examples/Collatz.sn -o collatz.bf
printf "7\n" | sanei collatz.bf- Language Reference: syntax, types, functions, arrays, I/O, and control flow.
- Compiler:
sanecusage, backends, diagnostics, and symbol annotations. - Interpreter And Debugger:
saneiusage, optimizations, and debugger commands. - Architecture: compilation pipeline, IR, tape layout, and implementation notes.
- Changelog: release history.
The examples are complete programs rather than syntax test cases:
| Program | Description |
|---|---|
examples/toy_aes_round.sn |
Runs an AES-inspired encrypt/decrypt round trip. |
examples/Collatz.sn |
Prints a Collatz sequence using a byte function. |
Build the binaries and run the full test suite:
cargo build
cargo testRun a development binary without installing it:
cargo run --bin sanec -- --help
cargo run --bin sanei -- --help- Recursive functions and richer call-frame strategies.
- Additional integer widths and pointer types.
- Safer dynamic array indexing.
- Further PC-backend code-size and dispatch optimizations.
- A module or file system for larger programs.
Sane is available under the MIT License.