A C++ written Brainfuck interpreter.
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:
- The unit of a memory cell is byte (8 bits);
- The size of the memory dynamically grows;
- Byte overflow (adding on a memory cell with value 255) will cause the byte to be back to zero;
- Byte underflow (decreasing on a memory cell with value 0) will cause the byte to be 255;
- 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;
- 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.
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.
Pass the Brainfuck code file name as the first argument of the executable. An example is as below:
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:
- Error and file checking;
- Debugging mode.
This source code is unlicensed. Any user can distribute or modify it freely, although a reference to the author would be appreciated.