#! /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 SED script debugger/indenter/tokenizer/HTMLizer
### original script: http://sed.sf.net/grabbag/scripts/bf2c.sed