{"id":24586769,"url":"https://github.com/vstroebel/cranefack","last_synced_at":"2025-04-28T14:27:47.237Z","repository":{"id":57611166,"uuid":"371685184","full_name":"vstroebel/cranefack","owner":"vstroebel","description":"An optimizing brainfuck compiler","archived":false,"fork":false,"pushed_at":"2023-10-17T17:46:48.000Z","size":568,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T01:03:16.086Z","etag":null,"topics":["brainfuck","compiler","jit","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vstroebel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-05-28T11:55:27.000Z","updated_at":"2024-12-20T00:03:49.000Z","dependencies_parsed_at":"2023-01-21T15:17:19.039Z","dependency_job_id":"c93ae72e-0f73-43f1-ab1a-9d6846d764fd","html_url":"https://github.com/vstroebel/cranefack","commit_stats":{"total_commits":231,"total_committers":1,"mean_commits":231.0,"dds":0.0,"last_synced_commit":"6e61d9c89df52be1fbf6663752db1e59b1e4ebe1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstroebel%2Fcranefack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstroebel%2Fcranefack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstroebel%2Fcranefack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstroebel%2Fcranefack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vstroebel","download_url":"https://codeload.github.com/vstroebel/cranefack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251329048,"owners_count":21572037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brainfuck","compiler","jit","rust"],"created_at":"2025-01-24T06:14:21.229Z","updated_at":"2025-04-28T14:27:47.204Z","avatar_url":"https://github.com/vstroebel.png","language":"Rust","readme":"# Cranefack\n\n[![docs.rs badge](https://docs.rs/cranefack/badge.svg)](https://docs.rs/cranefack/)\n[![crates.io badge](https://img.shields.io/crates/v/cranefack.svg)](https://crates.io/crates/cranefack/)\n[![Rust](https://github.com/vstroebel/cranefack/actions/workflows/rust.yml/badge.svg)](https://github.com/vstroebel/cranefack/actions/workflows/rust.yml)\n\nA cranelift powered optimizing brainfuck compiler suite.\n\n## Commandline interface\n\nCranefack provides a command line utility to run, compile and benchmark programs.\n\n```shell\ncargo install cranefack-cli\n```\n\n### Run\n\nRun a program with interpreter or jit.\u003cbr\u003e\nPassing the `-v` option prints some statistics and execution time.\n\n```text\nUSAGE:\n    cranefack run [FLAGS] [OPTIONS] \u003cFILE\u003e\n\nFLAGS:\n        --debug-optimizations    Print statistics for optimization passes\n    -j, --jit                    Use JIT compiler\n    -v, --verbose                \n        --wrapping-is-ub         Wrapping overflows are undefined behavior during optimization\n    -h, --help                   Prints help information\n    -V, --version                Prints version information\n\nOPTIONS:\n        --jit-level \u003clevel\u003e    Optimization level for JIT [possible values: none, speed, speed_and_size]\n    -O \u003cmode\u003e                  Optimization mode [default: 2]  [possible values: 0, 1, 2, 3, s, wtf]\n\nARGS:\n    \u003cFILE\u003e    Brainfuck source file. Use - to read from stdin\n```\n\n### Compile\n\nCompile the program.\u003cbr\u003e\nAs of now this will create an assembly like representation by default that is only useful for debugging.\u003cbr\u003e\nIn case you need something to compile into a native binary you can use the `rust` output format to get ugly rust code\nthat can be compiled with rustc:\n\n```shell\ncranefack compile -f=rust some_app.bf \u003e some_app.rs\nrustc -O some_app.rs\n./some_app\n```\n\n```text\nUSAGE:\n    cranefack compile [FLAGS] [OPTIONS] \u003cFILE\u003e\n\nFLAGS:\n        --debug-optimizations    Print statistics for optimization passes\n    -v, --verbose                \n        --wrapping-is-ub         Wrapping overflows are undefined behavior during optimization\n    -h, --help                   Prints help information\n    -V, --version                Prints version information\n\nOPTIONS:\n    -f, --format \u003cformat\u003e      Format of compiled code [default: dump]  [possible values: dump, clir, rust]\n        --jit-level \u003clevel\u003e    Optimization level for JIT [possible values: none, speed, speed_and_size]\n    -O \u003cmode\u003e                  Optimization mode [default: 2]  [possible values: 0, 1, 2, 3, s, wtf]\n\nARGS:\n    \u003cFILE\u003e    Brainfuck source file. Use - to read from stdin\n```\n\n### Benchmark\n\nRuns a program with different optimization settings and returns a table this the time for each program run.\n\n```text\nUSAGE:\n    cranefack benchmark [FLAGS] [OPTIONS] \u003cFILE\u003e\n\nFLAGS:\n    -j, --jit               Only benchmark jit\n    -o, --optimized-only    Don't benchmark O0\n    -h, --help              Prints help information\n    -V, --version           Prints version information\n\nOPTIONS:\n    -i, --iterations \u003cITERATIONS\u003e    Number of benchmarking iterations [default: 2]\n    -r, --runs \u003cRUNS\u003e                Number of runs per optimization in each round [default: 4]\n\nARGS:\n    \u003cFILE\u003e    Brainfuck source file. Use - to read from stdin\n```\n\n## Use cranefack as a library\n\nTo use cranefack as a library add the following to your Cargo.toml dependencies:\n\n```toml\ncranefack = \"0.4\"\n```\n\nTo run a program with jit compilation:\n\n```rust\nuse std::error::Error;\nuse cranefack::{parse, optimize_with_config, OptimizeConfig, CompiledJitModule};\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n\n    // Parse program\n    let mut program = parse(\"++[\u003c].\")?;\n\n    // Create optimization config for level 2\n    let opt_level = OptimizeConfig::o2();\n\n    // Optimize with optimization level 2\n    optimize_with_config(\u0026mut program, \u0026opt_level);\n\n    // Compile program into module\n    let module = CompiledJitModule::new(\u0026program, \u0026opt_level)?;\n\n    // Execute compiled module reading from stdin and writing to stdout\n    module.execute(std::io::stdin(), std::io::stdout());\n\n    Ok(())\n}\n```\n\n## License\n\nThis project is licensed under either of\n\n* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)\n* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in cranefack by you, as\ndefined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvstroebel%2Fcranefack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvstroebel%2Fcranefack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvstroebel%2Fcranefack/lists"}