bf2fj


Namebf2fj JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://esolangs.org/wiki/FlipJump
SummaryA brainfuck to flipjump compiler
upload_time2023-12-12 12:20:16
maintainer
docs_urlNone
authorTom Herman
requires_python>=3.8.1,<4.0.0
licenseBSD-2-Clause-Simplified
keywords esolang oisc assembly
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![GitHub](https://img.shields.io/github/license/tomhea/bf2fj)](LICENSE)
[![Website](https://img.shields.io/website?down_color=red&down_message=down&up_message=up&url=https%3A%2F%2Fesolangs.org%2Fwiki%2FFlipJump)](https://esolangs.org/wiki/FlipJump)
[![PyPI - Version](https://img.shields.io/pypi/v/bf2fj)](https://pypi.org/project/bf2fj/)

# bf2fj
A [Brainfuck](https://esolangs.org/wiki/Brainfuck) to [FlipJump](https://github.com/tomhea/flip-jump) 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. 

## Download:
```
>>> pip install bf2fj
```

## 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 (just omit the `--compile-only` flag), but I only added the input / expected-output files to only a portion of the tests, so it won't pass.

## 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://esolangs.org/wiki/FlipJump",
    "name": "bf2fj",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0.0",
    "maintainer_email": "",
    "keywords": "esolang,oisc,assembly",
    "author": "Tom Herman",
    "author_email": "flipjumpproject@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/95/bb/b9cbfc3f561f2387e029536b0039d6d649170574877cf866ebb293bea431/bf2fj-1.0.1.tar.gz",
    "platform": null,
    "description": "[![GitHub](https://img.shields.io/github/license/tomhea/bf2fj)](LICENSE)\n[![Website](https://img.shields.io/website?down_color=red&down_message=down&up_message=up&url=https%3A%2F%2Fesolangs.org%2Fwiki%2FFlipJump)](https://esolangs.org/wiki/FlipJump)\n[![PyPI - Version](https://img.shields.io/pypi/v/bf2fj)](https://pypi.org/project/bf2fj/)\n\n# bf2fj\nA [Brainfuck](https://esolangs.org/wiki/Brainfuck) to [FlipJump](https://github.com/tomhea/flip-jump) Compiler.\n\nThe 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. \n\n## Download:\n```\n>>> pip install bf2fj\n```\n\n## Run the compiler:\n\n```\n>>> bf2fj hello_world.bf \n  compile bf->fj:  0.008s\n```\n\nYou can also run the created flipjump program.\n```\n>>> bf2fj hello_world.bf -r\n  compile bf->fj:  0.008s\n  parsing:         0.092s\n  macro resolve:   0.141s\n  labels resolve:  0.035s\n  create binary:   0.143s\n  loading memory:  0.017s\nHello World!\n\nFinished by looping after 0.739s (337,484 ops executed; 85.36% flips, 98.88% jumps).\n```\n\nNote that you can modify the number of brainfuck cells that'll be reserved in the flipjump file, with `-c` / `--cells`.\n\n## Optimizations\nThis compiler supports optimizations of the generated flipjump code.  \n\nThe optimizations are significant. It lowered the hello_world.bf program from 2,900,990 fj ops to 337,484 fj ops (88% faster).\n\nThe major optimizations strategies:\n- Optimize multiple data ops: `+++++` => `+5`, and `----++-` => `-3`.\n- Optimize multiple pointer ops: `>>>>>` => `>5`, `<<<<>><` => `<3`.\n- Find zeroing loops, and replace them with `*ptr = 0`. If there are data-ops before it, removes them too.\n- `*ptr = 0` + `+5` => `*ptr = 5`.\n\n## Tests:\nI've gathered many brainfuck programs, and put them all inside the programs/ folder.  \nThe tests compile each of them to flipjump:\n```\n>> pytest --compile-only\n```\nYou can also run the compiled flipjump files (just omit the `--compile-only` flag), but I only added the input / expected-output files to only a portion of the tests, so it won't pass.\n\n## Licenses:\nThe 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.\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause-Simplified",
    "summary": "A brainfuck to flipjump compiler",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://esolangs.org/wiki/FlipJump",
        "Repository": "https://github.com/tomhea/bf2fj"
    },
    "split_keywords": [
        "esolang",
        "oisc",
        "assembly"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "874b6e0fdc27d60c5021b78ea035514aa517aac3ed579518ade45dc8055873d8",
                "md5": "ec8bf14869cf8412c3681b091d91e207",
                "sha256": "77c2a35e733dd734ac2cef92f3917ad5895fd73ef2d8a982b1113c8ffdff0bd0"
            },
            "downloads": -1,
            "filename": "bf2fj-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ec8bf14869cf8412c3681b091d91e207",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0.0",
            "size": 11967,
            "upload_time": "2023-12-12T12:20:15",
            "upload_time_iso_8601": "2023-12-12T12:20:15.408772Z",
            "url": "https://files.pythonhosted.org/packages/87/4b/6e0fdc27d60c5021b78ea035514aa517aac3ed579518ade45dc8055873d8/bf2fj-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95bbb9cbfc3f561f2387e029536b0039d6d649170574877cf866ebb293bea431",
                "md5": "5ee4162f11aff1471a72b1373304b554",
                "sha256": "f4b6edb868d951c95101a77786c14df1d7660bc0cfdc2c96fed86ec31e6cccd3"
            },
            "downloads": -1,
            "filename": "bf2fj-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5ee4162f11aff1471a72b1373304b554",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0.0",
            "size": 10943,
            "upload_time": "2023-12-12T12:20:16",
            "upload_time_iso_8601": "2023-12-12T12:20:16.979468Z",
            "url": "https://files.pythonhosted.org/packages/95/bb/b9cbfc3f561f2387e029536b0039d6d649170574877cf866ebb293bea431/bf2fj-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-12 12:20:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tomhea",
    "github_project": "bf2fj",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "bf2fj"
}
        
Elapsed time: 0.16892s