This is a Prolog implementation of a Brainfuck interpreter. Brainfuck is an esoteric programming language with only eight commands, making it one of the simplest programming languages.
To run the Brainfuck interpreter written in Prolog, you'll need to first install SWI-Prolog .
To install SWI-Prolog on Linux, open up a terminal and type:
sudo apt-get install swi-prolog
On macOS, if you have Homebrew installed you can instead run:
brew install swi-prolog
To install SWI-Prolog on Windows, download the installer from the official website and follow the instructions.
-
Open your terminal or command prompt and navigate to the directory where you want to clone the repository.
-
Clone the repository:
git clone https://github.com/afvanwoudenberg/bf.git
- Navigate into the project folder:
cd bf
Once you have SWI-Prolog installed and have cloned this repository, you can run Brainfuck programs using the run_bf_program/1
predicate.
This repository includes some programs from the The brainfuck archive.
First, start the SWI-Prolog interpreter by opening up a terminal and typing:
swipl
This will start the Prolog interpreter. You can then load the Brainfuck interpreter by typing:
[bf].
This loads the bf.pl
file into the interpreter. You can then run a Brainfuck program using the run_bf_program/1
predicate, like so:
run_bf_program('hellobf.bf').
This will run the hellobf.bf
program and output the famous "Hello World!" message to the console.
Alternatively, you can execute these three steps at once by typing:
swipl -s bf.pl -g "run_bf_program('hellobf.bf'), halt."
Adding halt
will make the Prolog interpreter exit after the Brainfuck run_bf_program/1
predicate has finished.
Aswin van Woudenberg (afvanwoudenberg)
This project is licensed under the MIT License - see the LICENSE file for details.