Skip to content
A C++ written Brainfuck interpreter.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
.gitattributes
BfInterpreter.exe
LICENSE
README.md

README.md

Brainfuck-Interpreter

A C++ written Brainfuck interpreter.

Author

Douglas Liu
Github: https://github.com/DouglasLiuGamer

Description

This is a Brainfuck interpreter written in C++ with object-oriented design. Given the reason that there is no formal Brainfuck standard, the interpreter shall interpret Brainfuck code as below:

  1. The unit of a memory cell is byte (8 bits);
  2. The size of the memory dynamically grows;
  3. Byte overflow (adding on a memory cell with value 255) will cause the byte to be back to zero;
  4. Byte underflow (decreasing on a memory cell with value 0) will cause the byte to be 255;
  5. No code error checking. Any wrong Brainfuck code (such as left moving the pointer when it points to the first memory cell) will cause undefined consequences;
  6. No file checking. It is the user's responsibility to ensure that the code file can be opened.

The choice of using object-oriented design is simply for learning purpose. It is silly to apply object-oriented design in such an interpreter, really.

Usage Manual

Compilation

Please using any C++ compiler to compile and link all the .cpp files in folder src into one executable file. An example of using g++ is as below:

g++ BfCode.cpp BfMachine.cpp Byte.cpp Memory.cpp BfInterpreter.cpp -o BfInterpreter.exe

An executable compiled in Windows 10 is provided.

Running

Pass the Brainfuck code file name as the first argument of the executable. An example is as below:

BfInterpreter.exe HelloWorld.bf

Update Plan

Currently there is no update plan for this program, because it seems that the only user of this program is the author myself. Given extra time and motivation, following update plan may be conducted:

  1. Error and file checking;
  2. Debugging mode.

License

This source code is unlicensed. Any user can distribute or modify it freely, although a reference to the author would be appreciated.

You can’t perform that action at this time.