a simple Python-based brainfuck interpreter that executes code and processes input/output.
- supports all BF commands (
>
,<
,+
,-
,.
,,
,[
,]
) - processes user input, handles output
- covers loops and conditional logic
all the brainfuck commands:
Command | Description |
---|---|
> |
move the pointer to the right |
< |
move the pointer to the left |
+ |
increment the byte at the pointer |
- |
decrement the byte at the pointer |
. |
output the byte at the pointer as a character |
, |
accept one byte of input, stores value in the current cell |
[ |
jump to the matching ] if the byte at the pointer is 0 |
] |
jump back to the matching [ if the byte at the pointer is non-zero |
run brainfuck.py to start the interpreter. enter your code and then use the following commands:
Command | Description |
---|---|
:run |
executes the code |
:clear |
clears the accumulated code |
:exit |
exits the program |
hello world example using the interpreter:
welcome to brainfuck!
type your code below. enter ':run' to execute, ':clear' to clear the code, or ':exit' to quit.
Brainfuck> >++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<++.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-]<+.
Brainfuck> :run
output: Hello, World!
to run the interpreter:
- clone the repo:
git clone https://github.com/your-username/brainfuck-interpreter.git
- cd into the project:
cd brainfuck-interpreter
- run brainfuck.py and write your code
python brainfuck.py
brainfuck.py: contains the core implementation of the interpreter.
README.md: docs.
contributions welcome.