Brainfuck interpreter with pre-compiled bracket map and configurable instruction limits.
- 8 standard commands (
> < + - . , [ ]), all other characters are ignored - 33,000-cell tape of
u8values with wrapping arithmetic - Cells 0–29,999: normal workspace; cells 30,000–32,004: memory-mapped I/O region
- Pre-compiles a
HashMap<usize, usize>bracket map for O(1) jump lookups - Default instruction limit: 10,000,000 (configurable via
with_instruction_limit()) - Detects unmatched brackets at compile time before execution begins
The tape region from cell 30,000 onward provides HTTP, KV storage, and environment variable access without any new commands:
| Region | Cells | Purpose |
|---|---|---|
| URL / Key buffer | 30,000–30,499 | Write URL or KV key here |
| Body / Value buffer | 30,500–30,999 | Write POST body or KV value here |
| Response buffer | 31,000–31,999 | Read response data here |
| IO_STATUS | 32,000 | HTTP status or success flag |
| IO_METHOD | 32,001 | 1=GET, 2=POST, 3=KV_GET, 4=KV_SET, 5=KV_DEL, 6=ENV |
| IO_RESP_LEN | 32,002–32,003 | Response length (big-endian u16) |
| IO_EXEC | 32,004 | Write non-zero here to trigger the I/O operation |
cargo install --path .
# Inline code
bf "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++."
# From file
bf -f program.bf
# Piped input (for , commands)
echo "hello" | bf ",+.>,.>,."use otherfunc_brainfuck::BrainfuckInterpreter;
use otherfunc_core::Interpreter;
let mut bf = BrainfuckInterpreter::new();
let output = bf.execute("++++++[>++++++++++<-]>+++++.", "").unwrap();
assert_eq!(output, "A");cargo test -p otherfunc-brainfuck # 19 tests