#language #tui #terminal-based #addition

bin+lib brainfoamkit

An interpreter for the brainf*** language

17 releases (1 stable)

1.0.0 Jan 5, 2024
1.0.0-beta.1 Dec 28, 2023
1.0.0-alpha.14 Jan 1, 2024
1.0.0-alpha.8 Aug 26, 2023
1.0.0-alpha.4 Jul 5, 2023

#164 in Programming languages

Download history 22/week @ 2023-12-25 16/week @ 2024-01-01 40/week @ 2024-02-26 205/week @ 2024-04-01

205 downloads per month

MIT/Apache

11MB
4K SLoC

Rust 3.5K SLoC // 0.2% comments JavaScript 408 SLoC // 0.1% comments Handlebars 72 SLoC Shell 57 SLoC // 0.3% comments TypeScript 21 SLoC // 0.8% comments

Contains (ELF exe/lib, 680KB) bfkrun-x86_64-unknown-linux-musl, (ELF exe/lib, 530KB) bfkview-aarch64-unknown-linux-gnu, (ELF exe/lib, 570KB) bfkrun-aarch64-unknown-linux-musl, (ELF exe/lib, 595KB) bfkview-aarch64-unknown-linux-musl, (ELF exe/lib, 565KB) bfkrun-i686-unknown-linux-gnu, (ELF exe/lib, 570KB) bfkview-i686-unknown-linux-gnu and 14 more.

Brainfoamkit

GitHub release (latest by date) GitHub tag (latest SemVer) Continuous integration Contribute with Gitpod

This project aims to implement a brainfuck interpreter in Rust. In addition, this also aims to provide a terminal-based TUI for stepping through and understanding the brainfuck programs.

Builds

Platform Rust Version Status
Linux stable
beta
nightly
MSRV (1.70.0)
Ubuntu x Stable Rust
Ubuntu x Beta Rust
Ubuntu x Nightly Rust
Ubuntu x MSRV Rust
Windows stable
beta
nightly
MSRV (1.70.0)
macos x Stable Rust
macos x Beta Rust
macos x Nightly Rust
macos x MSRV Rust
macOS stable
beta
nightly
MSRV (1.70.0)
Windows x Stable Rust
Windows x Beta Rust
Windows x Nightly Rust
Windows x MSRV Rust

Rationale

Brainfuck is an interesting esoteric language. It is turing complete and can essentially be used as a general purpose programming language. However, it has only 8 individual symbols that are used to instruct the interpreter. This makes it both fun and challenging to implement.

While several C and C++ interpreters for Brainfuck exist, I believe that it is particularly well suited for implementation in Rust due the combination of memory-safety, speed and zero-cost abstractions. Additionally, the interpreter is expected to be non-trivial in complexity while still only scratching the surface of the features Rust has to offer. Thus, it provides an excellent educational opportunity for someone trying to learn Rust.

Implementation Details

Briefly, the interpreter is implemented as a Virtual Machine on top of the existing Rust runtime. This frees us from low-level hardware constraints, allowing us to focus on the core of the program. The language remains focused on 8-byte operations and the ASCII code, allowing for rust to shine as a fast language.

More details regarding the implementation, including an EBNF grammar and other design tradeoffs can be found in the lang directory.

(Planned) Features

  • A complete brainfuck interpreter capable of ingesting a brainfuck program and behaving appropriately
  • A modular system for the said interpreter, allowing for extensions and modifications
  • A configurable brainfuck virtual machine to interpret the programs.
  • A fully capable TUI to visualize and step through a brainfuck program

Current Status

  • Implement basic building blocks for the Virtual Machine
  • Implement the Virtual Machine to run the code
  • Implement a parser for parsing the input program
  • Design the TUI for the visualizer
  • Implement the TUI with the Virtual Machine and parser

Contributing

See the Contributing for details on how to contribute to the project.

You can contribute to the project through GitPod.

Open in Gitpod

Code of Conduct

This project is governed by the Contributor Code of Conduct Covenant. Details are outlined in the CODE OF CONDUCT.

Dependencies

~10–21MB
~267K SLoC