Skip to content

Efficient interpreter for Brainfuck with 8-bit cells by compiling Brainfuck to bytecode

Notifications You must be signed in to change notification settings

seb711/brainfuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brainfuck Compiler and Interpreter

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.

Prerequisites

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)

Compilation

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

Usage

Compiler

The Brainfuck compiler can be used to compile Brainfuck source code into bytecode. It takes two command-line arguments:

  1. The path to the Brainfuck source code file.
  2. The path where the compiled bytecode will be stored.

Example usage:

./bin/bf_compiler testing/hello_world.bf bytecode.bin

Interpreter

The Brainfuck interpreter is used to execute bytecode generated by the compiler. It takes one command-line argument:

  1. The path to the compiled bytecode file.

Example usage:

./bin/bf_interpreter bytecode.bin

Sample Files

Sample Brainfuck source code files are provided in the testing directory for testing the compiler and interpreter.

About

Efficient interpreter for Brainfuck with 8-bit cells by compiling Brainfuck to bytecode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published