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
    };
    >
)

// `@<character>` is treated as a number equal to ASCII/UNICODE code of the character.
@B+ . @B- @F+ . @F- @! .
#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.5.0.tar.gz (12.9 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.5.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rainduck-0.5.0.tar.gz
Algorithm Hash digest
SHA256 cb29cd7a644c3087bd4bf89160c7c72d76d753777723a4987f710a6faa6ec820
MD5 6ad187c83c5fb0cc2b668ca98080a451
BLAKE2b-256 3e7c30e2f21a37d9a81229849a5e0c48c1640c1bcb2d7233901ca15a653c39b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rainduck-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b9e19152578e9dd5249528bb1b4c7dc5c2fc11edd2f3a1c6ff9894a930fa874
MD5 3982498048221f35b206b5712796a368
BLAKE2b-256 e82447aa8b0bbbca07c66fa7d5b9904cd3552846bd436fed059e96bbe498bc94

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