#! /bin/sed -f
s/[^][+<>.,-]//g
s/\([-+]\)/\1\1*p;/g
s/</p--;/g
s/>/p++;/g
s/\./putchar(*p);/g
s/,/*p=getchar();/g
s/\[/while (*p) {/g
s/\]/}/g
1 s/^/#include <stdio.h>\
int main(void){char *p=calloc(1,10000);/
$ s/$/}/

/./ !d

# Here is an example BF program
#
# +[>>+++++[<++++++>-]<[>++++[>++++++++<-]<[->+>.<<]>[-<+>]+++++
# [>+++++<-]>+++.-.<+++[>------<-]>.---------.<+++++[>++++++<-]>
# .--.[-]++++++++++.[-]<<-]>+++++[<++++++>-]>>[-]<<<[>++++[>++++
# ++++<-]>>[<.>>+<-]>[-<+>]<+<<+++++[->++++++<]>.--.<++++[>-----
# --<-]>.++++++++.<+++[>++++++<-]>.++++.[-]++++++++++.[-]<<-]<]

### colorized by sedsed, a debugger and code formatter for sed scripts
### original script: http://sed.sf.net/grabbag/scripts/bf2c.sed