This repository contains a Brainfuck compiler and interpreter written in C++. You can use these tools to compile Brainfuck source code into bytecode and then execute it.
Before using the Brainfuck compiler and interpreter, you need to have the following tools installed on your system:
- C++ compiler (e.g., g++)
- Make (optional but recommended for building)
To compile the Brainfuck compiler and interpreter, you can use the provided Makefile. There are three build targets:
all
: Compiles both the compiler and interpreter.compile
: Compiles only the compiler.interpreter
: Compiles only the interpreter.
To compile both the compiler and interpreter, execute the following command:
make all
To compile only the compiler, execute the following command:
make compiler
To compile only the interpreter, execute the following command:
make interpreter
The Brainfuck compiler can be used to compile Brainfuck source code into bytecode. It takes two command-line arguments:
- The path to the Brainfuck source code file.
- The path where the compiled bytecode will be stored.
Example usage:
./bin/bf_compiler testing/hello_world.bf bytecode.bin
The Brainfuck interpreter is used to execute bytecode generated by the compiler. It takes one command-line argument:
- The path to the compiled bytecode file.
Example usage:
./bin/bf_interpreter bytecode.bin
Sample Brainfuck source code files are provided in the testing
directory for testing the compiler and interpreter.