Skip to main content

A simple BrainFuck extension with macros

Project description

RainDuck

A simple BrainFuck extension with macros transpiled to BrainFuck.

Installation

Use pip to install RainDuck.

pip install rainduck

Usage

# transpiles code to BrainFuck
rainduck my-program.rd

# use your favourite BrainFuck compiler or interpreter
brainfuck my-program.bf

# or use pipe
rainduck my-program.rd --stdout | brainfuck

Run rainduck --help for more options.

Basic Syntax

// comments are created with '//'
let // if you want to define macros, you must start with the word 'let'
#import(../folder/file.rd) // imports all global macros in ../folder/file.rd
clear = {[-]} // macro without arguments
five_left = {5<} // integer repeats given string
ten_right = {-2five_left} // negative integer reverses string and turns > <-> < and + <-> -
error = {-3[+]} // loop cannot be inverted, this raises an error...
no_error = {-1 error} // ...but double iversion doesn't have effect, this raises no error
// using ?<element>:<element> syntax, you can specify normal and inverted version of some code:
move_left_to_zero = {?{<[<]}:{>[>]}}
move_right_to_zero = {-1move_left_to_zero} // >[>]
move_cell(
    from;
    to = < // default value for this argument
) = {from [- -1from to + -1to from] -1from}

// most whitespace characters are optional
copy_cell(from={};to={};storage=<)={from[--1from storage+-1storage to+-1to from]move(storage)-1from}
in // end of macro definitions
// follows executed code
move( // macro call
    { // code blocks are created with curly brackets...
        let five_left={5{<<>}} in // ...and can contain local macro definition...
        3 {five_left >} // ...but don't have to
    };
    >
)
#comment(This comment will be also in final brainfuck code.)

Contributing

Pull requests are welcome. I also welcome remarks about anything I've done incorrectly or improperly.

License

MIT

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

rainduck-0.4.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rainduck-0.4.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file rainduck-0.4.1.tar.gz.

File metadata

  • Download URL: rainduck-0.4.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for rainduck-0.4.1.tar.gz
Algorithm Hash digest
SHA256 3c388af5019ab4c6286648627be567193ff771280debb1e0291b58902585a776
MD5 8a952264be7d9d6e99a8c22cc2a7c8f7
BLAKE2b-256 29cb3ec8ce14a9eeef8cbb69acc4eae1c237e3bcc5cd4faa9dafafdeb7bebad1

See more details on using hashes here.

File details

Details for the file rainduck-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: rainduck-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for rainduck-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d86c17b8f49792f6bc0d85aa48717c0d4272e48e42b6c1fe8b08c272162f8c90
MD5 3f596b494f5d25e821f3d587248b3403
BLAKE2b-256 74a90a01cb182e1d6ed1771e4ff46b0c9d1cc2e7ff0414ce47d96f2418bfb6c1

See more details on using hashes here.

Supported by

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