simple_brainfuck
a very simple brainfuck interpreter.
Install
pip install simple-brainfuck
Python Usage
import simple_brainfuck
# simple usage
bf_program = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++."
mem, time_cost = simple_brainfuck.run(bf_program)
# run with input, output hook
# through memory_status,you can access the program memory space
def input_hook(memory_status:dict[int, int]) -> int:
import sys
try:
return ord(sys.stdin.read(1)) % 256
except:
return 255
def output_book(memory_status:dict[int, int], c:int):
print(chr(c), end="")
simple_brainfuck.run(bf_program, input_hook=input_hook, output_hook=output_hook)
# run program, finally output the memory statue
simple_brainfuck.run(bf_program, show_memory=True)
# run program, finally output time cost
# time cost does not include preprocessing time, just program running time
simple_brainfuck.run(bf_program, show_time=True)
CLI Usage
# run in CLI mode
python3 -m simple_brainfuck
# run file as program
python3 -m simple_brainfuck <filepath.bf>
# run file, output time cost
python3 -m simple_brainfuck <filepath.bf> --show-time
python3 -m simple_brainfuck <filepath.bf> -t
# run file, output final memory status
python3 -m simple_brainfuck <filepath.bf> --show-memory
python3 -m simple_brainfuck <filepath.bf> -m
Metadata
Release files for simple-brainfuck 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| simple_brainfuck-0.1.5.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| simple_brainfuck-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / simple_brainfuck-0.1.5.tar.gz
| Download URL | simple_brainfuck-0.1.5.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f35a59237b965a56fb97d23789d322392cb12b9415089ef535ae98da133f90ce
|
|
BLAKE2b-256 checksum How to use checksums |
d7f656e74baed6438c3fa8e559b85c977b1ab2ff505f9d9a3fd55ad9890fae02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.13.12 Windows/11
|
Release files / simple_brainfuck-0.1.5-py3-none-any.whl
| Download URL | simple_brainfuck-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87b8f8192a42589dd96a1c81a39390c58dd1b32c31c18f46ec7e82b8d1d26e5c
|
|
BLAKE2b-256 checksum How to use checksums |
eb4562f03028160522211c8cb1a26116b08b6f15bc0953da4d6e23b25915549d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.13.12 Windows/11
|