https://github.com/saphereye/brainfuck-interpreter
An implementation of a brainfuck interpreter in Rust
https://github.com/saphereye/brainfuck-interpreter
brainfuck-interpreter rust
Last synced: about 1 year ago
JSON representation
An implementation of a brainfuck interpreter in Rust
- Host: GitHub
- URL: https://github.com/saphereye/brainfuck-interpreter
- Owner: Saphereye
- Created: 2023-08-28T09:16:02.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-03T16:28:15.000Z (almost 2 years ago)
- Last Synced: 2025-02-04T20:17:48.864Z (over 1 year ago)
- Topics: brainfuck-interpreter, rust
- Language: Rust
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Brainf*ck interpreter in Rust 
Implemented a [brainf*ck](https://esolangs.org/wiki/Brainfuck) interpreter in Rust.
The logic for the programming language can be summarised as follows:
| Instruction | Description |
|-------------|-------------|
| `<` | head0 = head0 - 1 |
| `>` | head0 = head0 + 1 |
| `{` | head1 = head1 - 1 |
| `}` | head1 = head1 + 1 |
| `-` | tape[head0] = tape[head0] - 1 |
| `+` | tape[head0] = tape[head0] + 1 |
| `.` | tape[head1] = tape[head0] |
| `,` | tape[head0] = tape[head1] |
| `[` | if (tape[head0] == 0): jump forwards to matching `]` command. |
| `]` | if (tape[head0] != 0): jump backwards to matching `[` command. |
> source: arXiv:2406.19108
## Usage
The program has a bunch of helpful CLI commands. An example usage while using this repo:
```cargo run --release -- --input examples/serpinkski.b```
## Developing
To turn on the debug mode, the program must first be compiled in the `debug` profile.
Then while running the program set the `RUST_LOG` env variable (to `DEBUG`, `TRACE`, etc.).