A compiler for the brainfuck language.
Compiles the given BF program, either given a filename or receiving input piped from stdin.
The output is saved in, by default, ./a.s
, but can be controlled with the -o
option.
Available options:
Usage: bfc [OPTIONS] [FILE]
Arguments:
[FILE]
The file to run
If one is not provided, then reads a program from stdin
Options:
-o, --output <OUTPUT>
The output file
Use `-` for stdout
[default: a.s]
-m, --memsize <MEMSIZE>
The size of the memory tape
[default: 8192]
-l, --loops
Whether to perform simple loop flattening
-s, --scan
Whether to perform memory scan vectorization
-p, --partial-evaluation
Whether to perform partial evaluation
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Examples:
$ bfc prgm.bf -m 8192 -o prgm.s
$ bfc < prgm.bf | nvim
Interprets the given BF program, either given a filename or receiving input piped from stdin.
Usage: bf-interp [OPTIONS] [FILE]
Arguments:
[FILE]
The file to run
If one is not provided, then reads a program from stdin
Options:
-p, --profile
Whether to profile the given program
-m, --memsize <MEMSIZE>
The size of the memory tape
[default: 8192]
-l, --loops
Whether to perform simple loop flattening
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Examples:
$ bf-interp prgm.bf -m 8192
$ bf-interp -p < prgm.bf
Compiles the given program just-in-time and executes it. Provide it with a command-line argument filename, or pipe it a program through stdin.
Usage: bf-jit [OPTIONS] [FILE]
Arguments:
[FILE]
The file to run
If one is not provided, then reads a program from stdin
Options:
-m, --memsize <MEMSIZE>
The size of the memory tape
[default: 8192]
-l, --loops
Whether to perform simple loop flattening
-s, --scan
Whether to perform memory scan vectorization
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
An installation of LLVM 19.1 is required.
This installation must feature the llvm-config
binary, which most package distributions don't include.
Compile with Cargo with the environment variable LLVM_SYS_191_PREFIX
set to the installation directory of LLVM 19.1.
The binary executable is put in the target/[profile]
directory.
$ export LLVM_SYS_191_PREFIX='$HOME/llvm-19.1.3'
$ cargo build --release
$ ./target/release/bf-llvm # [filename] [options...]