Skip to main content

A brainfuck REPL.

Project description

A brainfuck REPL.

Installation

Pypi (recommended):

sudo pip3 install brainfoose

Manual installation using git master:

git clone https://github.com/abactel/brainfoose

cd brainfoose

pip install -r requirements.txt

sudo setup.py install

Usage

Usage:

brainfoose [--run_command=<programs>]

brainfoose [--tape_size=<tape_size>]

brainfoose [--verify_program=<tape_size>]

brainfoose (-h | --help)

brainfoose --version

Options:
-h, --help

Show this message

--version

Show version information

--run

Run a command without starting a REPL

--tape_size=<tape_size>

Set size of tape [default: 3000]

The syntax of the language is as follows:

Token

Meaning

?

Print a help screen

>

Increment the data pointer by 1.

<

Decrement the data pointer by 1.

+

Increment the value at the data pointer by 1.

-

Decrement the value at the data pointer by 1.

.

Output the byte at the data pointer. The byte is formatted to the character it represents.

,

Store a value at the data pointer’s position. The character is as a decimal byte representing the character. The character is accepted form a standard input prompt.

[

If the value at the data pointer is 0, move to matching ].

]

If the value at the data pointer is not 0, move to matching [.

$

Display tape up to last non-zero cell.

&

Reset tape.

%

Load program from file, syntax: %[filename].

The wikipedia page on brainfuck includes the following tutorial:

[ This program prints "Hello World!" and a newline to the screen, its
  length is 106 active command characters. [It is not the shortest.]

  This loop is an "initial comment loop", a simple way of adding a comment
  to a BF program such that you don't have to worry about any command
  characters. Any ".", ",", "+", "-", "<" and ">" characters are simply
  ignored, the "[" and "]" characters just have to be balanced. This
  loop and the commands it contains are ignored because the current cell
  defaults to a value of 0; the 0 value causes this loop to be skipped.
]
++++++++               Set Cell #0 to 8
[
    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
    [                   as the cell will be cleared by the loop
        >++             Add 2 to Cell #2
        >+++            Add 3 to Cell #3
        >+++            Add 3 to Cell #4
        >+              Add 1 to Cell #5
        <<<<-           Decrement the loop counter in Cell #1
    ]                   Loop till Cell #1 is zero; number of iterations is 4
    >+                  Add 1 to Cell #2
    >+                  Add 1 to Cell #3
    >-                  Subtract 1 from Cell #4
    >>+                 Add 1 to Cell #6
    [<]                 Move back to the first zero cell you find; this will
                        be Cell #1 which was cleared by the previous loop
    <-                  Decrement the loop Counter in Cell #0
]                       Loop till Cell #0 is zero; number of iterations is 8

The result of this is:
Cell No :   0   1   2   3   4s

Further reading

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

brainfoose-2.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

brainfoose-2.0.2-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file brainfoose-2.0.2.tar.gz.

File metadata

  • Download URL: brainfoose-2.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/37.0.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.6

File hashes

Hashes for brainfoose-2.0.2.tar.gz
Algorithm Hash digest
SHA256 a5719337aa3094379a56003ecfd34d393993a66b3364414d3058c3f68b5762c0
MD5 fd5a15380385b7cbb6f94c38c61cf490
BLAKE2b-256 3f7fcf4126bf89e2bf9157fa3efff3f7a0322b59e2912966e0f425ae55e272ca

See more details on using hashes here.

File details

Details for the file brainfoose-2.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: brainfoose-2.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/37.0.0 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/3.6.6

File hashes

Hashes for brainfoose-2.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0dd783764c01149a2801f52e2ed4ef30b391cd538d4213ee6c65432e442b3547
MD5 49d9dd2c8843f68322661d3a409ee5dd
BLAKE2b-256 4a3a9210e0db8fe311f1085620bca6082dd389d21f03551a4bda8b0831886649

See more details on using hashes here.

Supported by

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