Crates.io | bfup |
lib.rs | bfup |
version | 0.1.1 |
source | src |
created_at | 2023-02-22 20:52:19.353211 |
updated_at | 2023-10-01 10:24:02.628185 |
description | Preprocessor for brainfuck-like languages |
homepage | |
repository | https://github.com/kxlsx/bfup/ |
max_upload_size | |
id | 792122 |
size | 93,276 |
Preprocessor for brainfuck-like languages.
It allows the user, like every decent preprocessor should, to obfuscate their code with weird macros and obtuse syntax, even being able to arrange the output code in a rectangle of set width.
bfup is meant to be used primarily on top of brainfuck or languages with brainfuck-like syntaxes, as it operates mainly on single, utf-8 encoded characters. It is possible to wholly configure the recognized operators (characters) and the defined preprocessor directives' prefixes.
bfup [OPTIONS]... [FILE]
The list of all available flags can be seen by
using the --help
flag.
The program tries to preprocess the provided file, outputting only characters (to stdin by default) specified as operators (brainfuck operators by default). By default, the output is also arranged in a rectangle.
Recognized operators, as well as every directive character used by the parser can be configured with corresponding command-line options or read from a RON config file.
The preprocessor recognizes 5 basic types of 'tokens':
Token | Preprocessed as |
---|---|
Operators | copied directly to the output |
Tokens enclosed by ( ) |
groups the tokens and treats them as a single token. |
# followed by a number |
multiplies the next token number times |
$ followed by any character, followed by a token |
defines a macro that substitutes every subsequent occurrence of character with token |
\ |
skips the next character |
Code evaluating to a brainfuck program
that prints Hello World!
followed by a newline:
$z([-]) $p(.z)
$H(#72+p)
$e(#101+p)
$l(#108+p)
$o(#111+p)
$,(#44+p)
$ (#32+p)
$W(#87+p)
$r(#114+p)
$d(#100+p)
$!(#33+p)
$/(#10+p)
Hello, World!/
Be wary, that every character can be defined as a macro; you can overwrite operators, preprocessor directive prefixes and even whitespace characters. For example:
$+(-) $
< $$([[[-]]])
+++$
evaluates to:
<---([[[-]]])
In addition, macro definitions take the very first valid token they encounter, this means that:
$m($z$a+([-])aa)
mz
evaluates to:
++[-]
I appreciate any bug report/contribution/criticism.