Simple brainfuck interpreter in C
 
 
Go to file
Milo Fultz 55a1fdda07 Simplify increment/decrement 2022-07-26 17:04:36 +01:00
.gitignore Add gitignore 2022-02-20 11:54:03 -08:00
Makefile Add makefile 2022-03-03 08:31:51 -08:00
README Add debug messages, move to original spec 2022-03-03 08:29:13 -08:00
TODO Add notes on wrapping 2022-02-22 09:40:19 -08:00
brainfuck.c Simplify increment/decrement 2022-07-26 17:04:36 +01:00

README

# Brainfuck Interpreter

This interpreter will be able to take in basic tokens (e.g. `<`, `>`, etc. see
below) and output data as per the spec.


## The Spec

Commands are read from left to right, token by token, unless otherwise
specified. There is an instruction pointer, a data pointer, and memory to work
with, and they all can be modified by the commands below.

### Commands

Token | Effect
----- | ------
  >   | Increment the data pointer
  <   | Decrement the data pointer
  +   | Increment the byte at the data pointer
  -   | Decrement the byte at the data pointer
  .   | Output the byte at the data pointer
  ,   | Accept one byte of input and store at data pointer
  [   | If byte at data pointer is zero, jump to command after matching ]
  ]   | If byte at data pointer is not zero, jump to command after matching [

### Other Notes

This implementation is wrapping, meaning that the data bytes have an upper
limit of 255 and a lower limit of 0.

You can recompile with DEBUG set to 1 to get debug messages.


## Why Make This

It's a rite of passage, and I'm looking forward to exercising more in C, as
well as eventually getting into making languages myself, as well as learning
more about Lisp, Forth, parsers in general, etc.