bf-compiler
compiles a custom language brainfuck-c
(bfc) into Brainfuck, allowing for more complex and readable program creation in a higher-level syntax before being converted to Brainfuck.
git
cargo
- Clone the repository:
git clone https://github.com/justapig9020/bf-compiler
- Build the project:
cd bf-compiler cargo build
To compile a brainfuck-c
source file to Brainfuck, use the following command:
bf-compiler [OPTIONS] <SOURCE>
Arguments:
<SOURCE>
Options:
-o, --output <OUTPUT>
-h, --help Print help
-V, --version Print version
- AST: Function EOF
- Function: [Statement]*
- Statement: If | While | Assign | Move | Input | Output
- If: if Bool { Function } [else { Function }]!
- While: while Bool { Function }
- Assign: Variable = NUMBER
- Bool: Compare [&& Compare]*
- Compare: Equal | NotEqual
- Equal: Variable == NUMBER
- NotEqual: Variable != NUMBER
- Move: move_right | move_left
- Input: input ( Variable )
- Output: output ( Variable )
- Variable: ID
This project is part of a series aimed at building a compiler to prove that Brainfuck is Turing complete. You can find the other related projects here:
- tm-compiler: Converts Turing machines into a custom C-like IR (bf-c).
- bf-compiler: Compiles bf-c programs into Brainfuck.
- rubf: A Brainfuck virtual machine.
bf-compiler
is open-source and available under the MIT License. For more details, see the LICENSE file in the repository.