Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glanguage/bruck
Write brainfuck with ONLY square brackets.
https://github.com/glanguage/bruck
brainfuck bruck esolang esoteric
Last synced: about 6 hours ago
JSON representation
Write brainfuck with ONLY square brackets.
- Host: GitHub
- URL: https://github.com/glanguage/bruck
- Owner: GLanguage
- License: mit
- Created: 2022-05-01T12:07:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-02T12:34:36.000Z (over 2 years ago)
- Last Synced: 2024-10-30T21:49:09.357Z (16 days ago)
- Topics: brainfuck, bruck, esolang, esoteric
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bruck
Write brainfuck with ONLY square brackets.
```bruck
[]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][][[]][]][][
```![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bruck) [![PyPI](https://img.shields.io/pypi/v/bruck?color=blueviolet)](https://pypi.org/project/bruck/) ![GitHub](https://img.shields.io/github/license/GLanguage/bruck)
## Installation
```shell
$ pip install bruck
```## Usage
```shell
$ bruck [-veh] PROGRAM
```You can interpret a bruck program by
```shell
$ bruck .bruck
```Or run a program in command line by `-e` option. For example:
```shell
$ 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 nonzeroAll 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:
```bruck
][] []] [][
```And when you get familiar with the language, you can write something cool like this:
```bruck
[]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][]][][[][[]][]][]][][[]][][[[][[][[][[][][[]][]][]][][
```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
```python
from bruck.interpreter import *
```The `interpreter` module includes a class `BruckInterpreter` to interpret and execute bruck programs. Here is an example:
```python
from bruck.interpreter import *bruckInterpreter = BruckInterpreter('') # 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.