The first ever Brainfuck interpreter written in Eiffel
Brainfuck is an esoteric programming language created in 1993 by Urban Müller. It is notable for its extreme minimalism, consisting of only eight commands while being Turing complete. The language operates on an array of memory cells, each initially set to zero, with a pointer that can move to manipulate these cells.
>
: Move pointer right<
: Move pointer left+
: Increment current cell-
: Decrement current cell.
: Output current cell value as ASCII character,
: Input a character and store in current cell[
: Jump forward to matching]
if current cell is 0]
: Jump back to matching[
if current cell is not 0
Here's a simple "Hello, World!" program in Brainfuck:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
-
First, ensure you have the Serpent Eiffel compiler installed. Follow the installation instructions at Serpent's GitHub repository.
-
Clone this repository:
git clone https://github.com/samedit66/brainfuck.git cd brainfuck
-
Compile the project:
serpent build
-
Run the interpreter:
serpent run
The interpreter runs in an interactive REPL (Read-Eval-Print Loop) mode. When you start the interpreter, you'll see a welcome message and a prompt:
Welcome to Brainfuck interpreter!
Enter ':quit' to exit.
>
You can type Brainfuck code directly at the prompt and press Enter to execute it. The interpreter will immediately execute your code and show the output. After execution, it will show a new prompt for more input.
For example:
> ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
Hello World!
>
To exit the interpreter, type :quit
at the prompt.
This project is open source and available under the Apache License 2.0.