Skip to content

fymue/brainfuckc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brainfuckc

About

Brainfuck compiler/interpreter (bf) written in C.

This program can either be used as a compiler which compiles the bf code to C code or as an interpreter which interprets/runs the bf code right after parsing it.

Installation

Simply compile the bf.c file or use the provided Makefile

git clone https://github.com/fymue/brainfuckc.git
cd brainfuckc
make

Usage

Usage: ./bf [options] file.bf

Options:
-p, --parse  STR      parse STR as brainfuck code
-n, --tapesize N      specify the size of the tape (default: 30000)
-c, --compile         compile the brainfuck code to C code

Interpreter mode

The input bf code can either be provided as a string argument with the --parse option or as a .bf file:

./bf --parse "+++[>--[>]----[----<]>---]>>.---.->..>++>-----.<<<<--.+>>>>>-[.<]"
./bf path/to/bf_code.bf

Compiler mode

To use brainfuckc as a compiler, simply add the --compile option:

./bf --compile --parse "+++[>--[>]----[----<]>---]>>.---.->..>++>-----.<<<<--.+>>>>>-[.<]"
./bf --compile path/to/bf_code.bf

This will output a bf_code.c file (or whatever you named your .bf file + .c) which you can compile and execute yourself.