bf2fj
A Brainfuck to FlipJump Compiler.
The compiler was built to be very fast. Moreover, the flipjump programs generated by this project are generated in a way that will keep them very small, thus their compilation into an .fjm file is also fast.
See also the C to FlipJump Compiler.
Download:
>>> pip install bf2fj
Requires python 3.10-3.14.
Run the compiler:
>>> bf2fj hello_world.bf
compile bf->fj: 0.008s
You can also run the created flipjump program.
>>> bf2fj hello_world.bf -r
compile bf->fj: 0.008s
parsing: 0.092s
macro resolve: 0.141s
labels resolve: 0.035s
create binary: 0.143s
loading memory: 0.017s
Hello World!
Finished by looping after 0.739s (337,484 ops executed; 85.36% flips, 98.88% jumps).
Note that you can modify the number of brainfuck cells that'll be reserved in the flipjump file, with -c / --cells.
Optimizations
This compiler supports optimizations of the generated flipjump code.
The optimizations are significant. It lowered the hello_world.bf program from 2,900,990 fj ops to 337,484 fj ops (88% faster).
The major optimizations strategies:
- Optimize multiple data ops:
+++++=>+5, and----++-=>-3. - Optimize multiple pointer ops:
>>>>>=>>5,<<<<>><=><3. - Find zeroing loops, and replace them with
*ptr = 0. If there are data-ops before it, removes them too. *ptr = 0++5=>*ptr = 5.
Tests:
I've gathered many brainfuck programs, and put them all inside the programs/ folder.
The tests compile each of them to flipjump:
>> pytest --compile-only
You can also run the compiled flipjump files and verify their output (just omit the --compile-only flag).
Programs without input / expected-output files are skipped in this mode (they only get compile-tested),
and a few programs that are known to be unsupported are marked as expected-failures (see KNOWN_RUN_FAILURES in tests/test_cases.py).
Note that some of the programs (e.g. the quines) take many minutes to run.
Licenses:
The programs/ folder has a collection of 3rd party brainfuck programs, taken from multiple open-source websites. Each folder under programs/ has a README.md that specifies were the brainfuck files came from, and to whom we owe the credit.
Metadata
Release files for bf2fj 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bf2fj-1.0.4.tar.gz | 11.2 kB | Without provenance | Details for bf2fj-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bf2fj-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for bf2fj-1.0.4-py3-none-any.whl |
Total release size: 23.5 kB
Release files / bf2fj-1.0.4.tar.gz
| Download URL | bf2fj-1.0.4.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04eb1e2955c726e008c2d944f507b792f7e5598cf990b0737dd7012072b1ddb6
|
|
BLAKE2b-256 checksum How to use checksums |
e02156422137db344a955829243b10ea2d51c13f9f7773330fa5e971f290ab7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / bf2fj-1.0.4-py3-none-any.whl
| Download URL | bf2fj-1.0.4-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f9f005c5a291d1fbda542827fc44800b55db690f4c2da68295002f227d5bee8
|
|
BLAKE2b-256 checksum How to use checksums |
6dd4b2a587f0dda70b0822cd30753c850605a8553f800f892875970e86b91e13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Security for bf2fj 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.