github.com/pwseo/brainfuck-c

Brainfuck interpreter written in C99

Open this visualization on its own page →

Contributors

1

Lines of Code

100

From

2016-12-17

To

2021-01-25

About pwseo/brainfuck-c

This is a Brainfuck interpreter implemented in C99 that executes Brainfuck source code files passed as command-line arguments. Rather than directly interpreting the esoteric language's operations, the program first converts the source code into an optimized internal representation, which improves performance during execution.

The interpreter includes several optimization passes that simplify the compiled representation before running. It recognizes common patterns like loops that only increment or decrement a cell and replaces them with direct zero-assignment operations. Additionally, it collapses sequences of consecutive increment, decrement, and pointer movement instructions into single operations that perform the equivalent arithmetic and memory manipulations more efficiently.

Share this video