Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kopos/bff
Brainfuck compiler / interpreter / repl / JIT
https://github.com/kopos/bff
Last synced: 2 months ago
JSON representation
Brainfuck compiler / interpreter / repl / JIT
- Host: GitHub
- URL: https://github.com/kopos/bff
- Owner: kopos
- License: mit
- Created: 2016-01-24T03:27:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-24T17:25:56.000Z (about 9 years ago)
- Last Synced: 2024-04-24T16:14:40.106Z (9 months ago)
- Language: C
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeInterpreter - bff
README
# Brainfuck compiler / repl / interpreter / jits
## About
Teaching myself about the low-level stuff going on with a programming language.
Compilers, interpreters, JITs for a programming language. Have sailed the high
seas for far too long that the land is a distant memory.Teaching myself using the code at [https://github.com/nickdesaulniers/bf_interpreter_jit_compile]
## About Brainfuck
Brainfuck is an interesting, if hard to read, language. It only has eight
operations it can perform > < + - . , [ ], yet is Turing complete. There’s
nothing really to lex; each character is a token, and if the token is not one
of the eight operators, it’s ignored.## 8 language commands
Instruction | Description
----------- | -----------
> | increment the data pointer (to point to the next cell to the right).
< | decrement the data pointer (to point to the next cell to the left).
+ | increment (increase by one) the byte at the data pointer.
- | decrement (decrease by one) the byte at the data pointer.
. | output the byte at the data pointer.
, | accept one byte of input, storing its value in the byte at the data pointer.
[ | if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
] | if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.## Building
```
mkdir build
cd build
cmake ..
make
```## Usage
### The Interpreter
```
./interpreter ../code/hello_world.bf
```## References
1. http://nickdesaulniers.github.io/blog/2015/05/25/interpreter-compiler-jit/
2. http://en.wikipedia.org/wiki/Brainfuck