Just another rethink of the BrainFuck language
Project description
NeoBrainFuckInterpreter
NeoBrainFuckInterpreter is a Python interpreter for the Brainfuck programming language with additional commands for extended functionality.
Overview
This interpreter supports the basic Brainfuck commands (+
, -
, <
, >
, [
, ]
, .
, ,
) and introduces three additional commands:
$
: Switches IO mode to ASCII.%
: Switches IO mode to integers.^
: Jumps to a memory cell with an address equal to the value of the current memory cell.
The interpreter manages memory using a dynamic stack (MemoryStack
), allowing for negative indices and dynamic memory expansion.
Usage
Installation
Clone the repository:
git clone https://github.com/kusrabyzarc/NeoBrainF--k.git
cd NeoBrainF--k
Interpreter args
code: [str] BrainFuck code
do_debug: [bool] print debug info (default: False)
vanilla_cell_behaviour: [bool] clamp values in memory to range 0-255 (default: False)
vanilla_memory_stack: [bool] use static 30k-sized memory stack instead of dynamic (default: False)
Running the Interpreter
Run a Brainfuck program using the interpreter:
from NeoBrainFuckInterpretor.core import NeoBrainFuckInterpreter
code = "+[$,%.]" # Example Brainfuck program to input a symbol and get its ASCII code
itr = NeoBrainFuckInterpreter(code)
itr.run()
Another Example
from NeoBrainFuckInterpretor.core import NeoBrainFuckInterpreter
code = "%,>,<[->+<]>." # Example Brainfuck program to input 2 numbers and print sum
itr = NeoBrainFuckInterpreter(code, do_debug=True)
itr.run()
------------------------------------------------
Memory pointer: 0
Code pointer: 0 (%)
IO mode: ASCII
Memory neg_shift: -0
Memory: []:0:[]
------------------------------------------------
------------------------------------------------
Memory pointer: 0
Code pointer: 1 (,)
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[]
------------------------------------------------
1
------------------------------------------------
Memory pointer: 0
Code pointer: 2 (>)
IO mode: INT
Memory neg_shift: -0
Memory: []:1:[]
------------------------------------------------
------------------------------------------------
Memory pointer: 1
Code pointer: 3 (,)
IO mode: INT
Memory neg_shift: -0
Memory: []:1:[]
------------------------------------------------
2
------------------------------------------------
Memory pointer: 1
Code pointer: 4 (<)
IO mode: INT
Memory neg_shift: -0
Memory: []:1:[2]
------------------------------------------------
------------------------------------------------
Memory pointer: 0
Code pointer: 5 ([)
IO mode: INT
Memory neg_shift: -0
Memory: []:1:[2]
------------------------------------------------
------------------------------------------------
Memory pointer: 0
Code pointer: 6 (-)
IO mode: INT
Memory neg_shift: -0
Memory: []:1:[2]
------------------------------------------------
------------------------------------------------
Memory pointer: 0
Code pointer: 7 (>)
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[2]
------------------------------------------------
------------------------------------------------
Memory pointer: 1
Code pointer: 8 (+)
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[2]
------------------------------------------------
------------------------------------------------
Memory pointer: 1
Code pointer: 9 (<)
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[3]
------------------------------------------------
------------------------------------------------
Memory pointer: 0
Code pointer: 10 (])
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[3]
------------------------------------------------
------------------------------------------------
Memory pointer: 0
Code pointer: 11 (>)
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[3]
------------------------------------------------
------------------------------------------------
Memory pointer: 1
Code pointer: 12 (.)
IO mode: INT
Memory neg_shift: -0
Memory: []:0:[3]
------------------------------------------------
3
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file neobrainfuck-1.0.0.tar.gz
.
File metadata
- Download URL: neobrainfuck-1.0.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec57219f1ea73d102ebf7f8e18d6fdda486d4cd50c9b654025cafaadff1a0a2f |
|
MD5 | f29205b5cbfcd97abe6aa7d188f4b5f4 |
|
BLAKE2b-256 | 6d59936f93e70dfe9e739ec3da63c7d5a7e89dc2d2f58f4887c267f3911a2749 |
File details
Details for the file neobrainfuck-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: neobrainfuck-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94811c87319c4ad345767934a5117694775bb90831656083eed885cc20b8109d |
|
MD5 | 359ee8476456e187b5a558b1f2000bbb |
|
BLAKE2b-256 | 9c81e23b800b0f19d23d5c68e5b3333c81b1846b7a0f73598a96733e3c0282e7 |