# Simple brainfuck interpreter

bfi is a simple brainfuck interpreter, created as an experiment in interpreter and compiler design.

bfi is intended not as a stand-alone application, but as a building block for an eventual compiler. It parses the entire source and creates an Intermediate Representation before interpreting said IR, as a compiler would.
It implements simple peephole optimizations (truncating repeated + and - operations) and "brief format" error messages (the same format used in gcc and other compilers, for compatibility with Emacs' compilation-mode.

## Compilation
bfi is written as a single file of pure C, and depends only on libc. Thus, all you need to build it is a C compiler and make.
For a regular build, simply run:
make
For a build that logs the Intermediate Representation array to a file for debugging, run:
make debug_ir
The debug log file will be automatically created as "ir.log" if it doesn't already exist. By default, it will be created in the working directory. To change that, alter LOGPATH in main.c to your directory of choice.

## Usage
Simply run:
bfi -f file.bf
where file.bf is your Brainfuck source file. For an example Hello World program, use the provided hello.bf file.
For verbose output, add the -v argument.

## Media test
Let's see if pictures work. Here's lain with tux:
lain hugging tux, as it was meant to be
![lain hugging tux, as it was meant to be](/static/images/lain_linux.png)
Now let's do the same for video! Here's that vid for fel:

![video I recorded for felix earlier](/static/video/2026-02-20 10-48-54.mp4)