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.0.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.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rainduck-0.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 8687aa95e5ef6cbd5cfefbde2e867d75ddd4416978b4f1ef736f1eee97a9b063
MD5 7e148381d5745add94b8134d854bb0b5
BLAKE2b-256 10182d84d1fd7845afb4694b6fe9d684ce27351ae1e7318ee4cc99b47e3939c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rainduck-0.4.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfc54d555b69081f902ec3e6dc6c17b624204761a88c181f702491e8e9931d2d
MD5 79a7cac60807dc7ee31732c524a8f84f
BLAKE2b-256 4c90fcbe3e7e423df2b3fc810fd2fa3b906305d9f013311c9f25a5807e7869dd

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