Skip to main content

a very simple brainfuck interpreter.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_brainfuck-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_brainfuck-0.1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file simple_brainfuck-0.1.2.tar.gz.

File metadata

  • Download URL: simple_brainfuck-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Windows/11

File hashes

Hashes for simple_brainfuck-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3441344df0671696f5ab5ca5697b423c2a0bc9f66e762be04896d1f0ebe3dd7e
MD5 9b50895e2d902a22d41c8433ed57b7eb
BLAKE2b-256 2b9dad7f006f6d5fac268766cfdea683cedf9483ee4e5b191e4f4ec6261b822a

See more details on using hashes here.

File details

Details for the file simple_brainfuck-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: simple_brainfuck-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Windows/11

File hashes

Hashes for simple_brainfuck-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 518fc2a5a21fe64fad87c9fabc97ec8418f2b3bf02e18aa7fe8e681372cb0427
MD5 3b36fd3284977c0e4b1d79de9aa5a4b7
BLAKE2b-256 c5695a793e07b5065751267ea096fb869035888e4ada0c57061f76ac14cc02c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page