Skip to main content

Bruck

Write brainfuck with ONLY square brackets.

[]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][][[]][]][][

PyPI - Python Version PyPI GitHub

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.

Metadata

Release files for bruck 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bruck 0.1.0
File Size Uploaded
bruck-0.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bruck 0.1.0
File Interpreter ABI Platform
bruck-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / bruck-0.1.0.tar.gz

Download URL bruck-0.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3d0a65090a2509b9f08dd61f2b552d2a6dfd42e8d8dd3846fe8bf58b4dd42c41
BLAKE2b-256 checksum
How to use checksums
b9cd2344876ae33b32d40fefe2522bafd2b4cbd732dfbe30d219d430b48de982
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.0

Release files / bruck-0.1.0-py3-none-any.whl

Download URL bruck-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2182e5e1e542d3a23e69bd10e0f2c912f9e2ba20b0d97d170e9735a7ac246e7c
BLAKE2b-256 checksum
How to use checksums
748d3a4efc988b70e81128012df6526643baa35b657bc481a527b6c4157f36da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page