Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

brainfuck compiler

Replaces BF code by a C program with too many macros, then it delegates the heavy-lifting to the system's default C compiler via cc.

Inspired by "Tiny sh Brainfuck compiler". I wanted to make it even more portable by depending solely on cc: no sh, no POSIX utils, just ISO-C.

Usage

Compile the compiler 🤯

./build

Pipe BF to it:

# non-halting `cat`
printf %s '-[>,.<]' |
	./bfc > cat.c && \
	cc cat.c -o cat -O2 && \
	./cat

If you have bigger programs:

./bfc < tmp.bf > tmp.c && \
	cc tmp.c -o tmp -O2 && \
	./tmp