Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sane

Sane is a small programming language that compiles to 8-bit Brainfuck.

  • sanec compiles Sane source (.sn) to Brainfuck (.bf).
  • sanei runs 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.

Quick Start

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.bf

Expected 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

Documentation

Examples

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.

Development

Build the binaries and run the full test suite:

cargo build
cargo test

Run a development binary without installing it:

cargo run --bin sanec -- --help
cargo run --bin sanei -- --help

Roadmap

  • 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.

License

Sane is available under the MIT License.

About

programming language compiled to bf

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages