brainfuck interpreter
brainfuck cli rust
5

Configure Feed

Select the types of activity you want to include in your feed.

91 4 2

Clone this repository

https://tangled.org/digi.rip/tachyon https://tangled.org/did:plc:einebxrxfych2slzq7soxsyb
git@tangled.org:digi.rip/tachyon git@tangled.org:did:plc:einebxrxfych2slzq7soxsyb

For self-hosted knots, clone URLs may differ based on your setup.



README.md

tachyon#

a brainfuck interpreter written in rust.

warning!: my first rust project and my first interpreter. bad code everywhere. you have been warned!

features#

  • standard 30,000 byte tape with configurable length, pre-filled with 0s.
  • data pointer out-of-bounds behavior: error (crash on bounds violation, default) or wrap (wrap around).
  • cell value out-of-bounds behavior: wrap (wrapping 8-bit, default) or error (crash on overflow/underflow).
  • ascii i/o (default) and raw 8-bit numeric i/o for input and output.
  • syntax diagnostics: catches unmatched brackets before execution.
  • unit tests covering instructions, loops, nesting, out-of-bounds behaviors, and i/o modes.

building#

cargo build --release

usage#

./target/release/tachyon [OPTIONS] <PATH>

run a brainfuck script:

./target/release/tachyon path/to/your/script.bf

use wrapping data pointer and raw i/o:

./target/release/tachyon -d wrap -i raw -o raw script.bf

set a custom tape size of 100 cells:

./target/release/tachyon -l 100 script.bf

crash on cell overflow instead of wrapping:

./target/release/tachyon -c error script.bf

options#

flag description values
-d, --data-oob data pointer out-of-bounds behavior error (default), wrap
-c, --cell-oob cell value out-of-bounds behavior wrap (default), error
-l, --length custom tape length number (default: 30,000)
-i, --input-type input mode ascii (default), raw
-o, --output-type output mode ascii (default), raw
-p, --delay instruction delay in ms (pairs well with tracing) default: 0
-t, --tracing print tape state after every cycle default: false

roadmap#

features and milestones! nothing is guaranteed to happen. less of a roadmap and more a list of things i'd like to do

this is all pretty overkill but im using this project as a way to learn stuff

cli#

  • argument parsing: possibly switch to clap for nicer cli experience
  • behavior flags: overrides defaults in code (& possibly eventually in config?)
    • set data pointer & cell value behavior
    • set custom tape size
  • 8-bit i/o: add 8-bit input/output option alongside ascii default
    • monomorphization: implement input/output strategy for minor optimization gains
  • config file: set up per-project config file for input & output

out-of-bounds behaviors#

  • data pointer behavior
    • error (default): crash when moving past tape boundaries
    • wrap: going out of bounds wraps around to start/beginning
  • cell value behavior
    • wrap (default): 0 - 1 = 255
    • error: crash on overflow/underflow

better diagnostics#

  • errors: switch to miette for richer error display with source snippets
  • tracing: cli flag to print state of vm/tape after every instruction

visualization#

  • real-time cell visualization: tui showing tape being adjusted and data pointer moving in real time at adjustable speed
  • wasm: compile to wasm for browser-based frontend?

debugging#

  • step debugger: REPL-style debugger with breakpoints, cell inspection, and instruction stepping

maintenance#

  • comprehensive testing: for all instructions and out-of-bounds behaviors
  • benchmarking: use criterion to track performance?