Write brainfuck with ONLY square brackets.
Project description
Bruck
Write brainfuck with ONLY square brackets.
[]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][][[]][]][][
Installation
$ pip install bruck
Usage
$ bruck [-veh] PROGRAM
You can interpret a bruck program by
$ bruck <filename>.bruck
Or run a program in command line by -e
option. For example:
$ bruck -e '][][]['
-v
option shows version, and -h
option shows help.
Bruck Syntax
The syntax of bruck is basically the same as brainfuck, but was inspired by codons in DNA or RNA molecules. We use 3-character strings consisting of [
and ]
to represent 8 different commands in brainfuck.
Bruck | Equivalent Brainfuck | Description |
---|---|---|
[]] |
+ |
Increment the memory cell at the pointer |
[[] |
- |
Decrement the memory cell at the pointer |
]][ |
> |
Move the pointer to the right |
][[ |
< |
Move the pointer to the left |
[][ |
. |
Output the character signified by the cell at the pointer |
][] |
, |
Input a character and store it in the cell at the pointer |
[[[ |
[ |
Jump past the matching ]]] if the cell at the pointer is 0 |
]]] |
] |
Jump back to the matching [[[ if the cell at the pointer is nonzero |
All characters other than [
and ]
are ignored, including spaces and newlines. Having just started to use bruck, you may find it helpful to divide the program into commands:
][] []] [][
And when you get familiar with the language, you can write something cool like this:
[]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][][[][[]][]][]][][[]][][[[][[][[][[][][[]][]][]][][
Since the length of a bruck command is 3, the length of a bruck program (with only [
and ]
counted) must be divisible by 3, otherwise the interpreter will raise an error.
Error Messages
If an error occurs when executing a bruck program, the bruck interpreter will raise a BruckError
with error messages showing where and why the error has occured.
If you find the error messages generated by the interpreter a little difficult to understand, don't worry. It is a feature. Bruck is a so-called esoteric programming language, and therefore the bruck interpreter is also designed to be esoteric. You will be used to that soon.
API
A Python API is provided to interpret bruck programs. After installation, import the interpreter
module by
from bruck.interpreter import *
The interpreter
module includes a class BruckInterpreter
to interpret and execute bruck programs. Here is an example:
from bruck.interpreter import *
bruckInterpreter = BruckInterpreter('<bruck_program_string>') # Initialize
bruckInterpreter.exec() # Execute the program
For more help on the API, try help(BruckInterpreter)
after importing the module.
Contribution
If you find any bugs or have suggestions for new features, please raise an issue for further discussion. All contributions are welcomed.
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 bruck-0.1.0.tar.gz
.
File metadata
- Download URL: bruck-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d0a65090a2509b9f08dd61f2b552d2a6dfd42e8d8dd3846fe8bf58b4dd42c41 |
|
MD5 | a4cd57f053e1e27a22d5ccd021821e7a |
|
BLAKE2b-256 | b9cd2344876ae33b32d40fefe2522bafd2b4cbd732dfbe30d219d430b48de982 |
File details
Details for the file bruck-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: bruck-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2182e5e1e542d3a23e69bd10e0f2c912f9e2ba20b0d97d170e9735a7ac246e7c |
|
MD5 | 67b93ee6661ee7e129af9de6ad196da9 |
|
BLAKE2b-256 | 748d3a4efc988b70e81128012df6526643baa35b657bc481a527b6c4157f36da |