Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Brainfuck to C compiler

Name: Anonymous 2014-04-30 9:44


Brainfuck to C compiler
=======================

$ ls -l
42319 bf
2315 bf2c.bf
107 hello.bf
11452 mandel.bf
934 quine.bf
$ cat bf2c.bf
--[------->++<]>-.[->+++<]>.+++++.-----------.+++++++++.+++++++++.+[->+++<]>+
+.+.--[--->+<]>-.--[->++<]>.--[->++<]>-.+.++[->+++<]>++.+++++.++++++.[->+++++
<]>+++.+[--->+<]>+++.++[->+++<]>.>++++++++++.-[->++++<]>-.[->+++<]>.+++++.---
--------.+++++++++.+++++++++.+[->+++<]>++.+.--[--->+<]>-.--[->++<]>.--[->++<]
>-.+.++[->+++<]>++.+++++.+++++.++++++.[++>---<]>.+[--->+<]>+++.++[->+++<]>.>+
+++++++++.[--------->++<]>+.------------.+++++.++++++.[-->+<]>--.+[--->+++++<
]>.[--->+<]>-.[---->+<]>+++.[->+++<]>+.------.+[-->+<]>+++.-.++.++.[------>+<
]>-.[--->++<]>-.[->++<]>+.-[-->+++++<]>-.>--[-->+++<]>.-[++>---<]>+.[->++<]>-
.------------.+++++.++++++.[-->+<]>--.+[--->+++++<]>.[--->+<]>-.--[++>---<]>-
.--[--->++<]>.[-->+<]>+++++.+++[-->+++<]>+.+[------>+<]>.----[->++<]>-.------
------.++++++++.+++++.++[++>---<]>.+.[->+++<]>.--------.++++[->+++<]>.[--->+<
]>---.++[->+++<]>.[--->+<]>-.++[->+++<]>+.---[->+++<]>-.--[->+++<]>+.+.++[->+
++<]>++.+++++++++++.++++++.-.[++>---<]>--.-----[->++<]>.+++++++.---------..[-
->+<]>+++.-[-->+++<]>-.>+[>[-],>[-]+>[-]+>[-]+>[-]+>[-]+>[-]+>[-]+>[-]+>[-]+<
<<<<<<<<----------[>-<---------------------------------[>>-<<-[>>>-<<<-[>>>>-
<<<<-[>>>>>-<<<<<--------------[>>>>>>-<<<<<<--[>>>>>>>-<<<<<<<--------------
---------------[>>>>>>>>-<<<<<<<<--[>>>>>>>>>-<<<<<<<<<[-]]]]]]]]]]>[<<->>>>>
>>>>>><[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]]<>>[>>>>>>>>++[------>+<]>..-.--[-
-->++<]>.[-->+<]>+++.<<<<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]]<<>>>[>>>>>>>++[----
-->+<]>-.--[--->++<]>.[-->+<]>+++++.--[--->+<]>--.--.[--->+<]>---.++[->+++<]>
+.+++++.-------.--[--->+<]>---.[--->+<]>++.+.-[-->+++<]>-.<<<<<<<<<<[-]<[-]<[
-]<[-]<[-]<[-]<[-]]<<<>>>>[>>>>>>++[------>+<]>++..---.--[--->++<]>.[-->+<]>+
++.<<<<[-]<[-]<[-]<[-]<[-]<[-]]<<<<>>>>>[>>>>>+[------->++<]>++.+++++.-.++[->
+++<]>+.+++++.-------.--[--->+<]>---.[--->+<]>++.++.--[--->++<]>.[++>---<]>+.
-[-->+++<]>-.<<<<<<<<[-]<[-]<[-]<[-]<[-]]<<<<<>>>>>>[>>>>++[------>+<]>++..--
[----->+<]>+.[-->+<]>+++.<<<<[-]<[-]<[-]<[-]]<<<<<<>>>>>>>[>>>++[------>+<]>.
.[----->+<]>+.[-->+<]>+++.<<<<[-]<[-]<[-]]<<<<<<<>>>>>>>>[>>------[-->+++<]>.
+[->+++<]>.+.+++.-------.--[->+++<]>-.++.--[--->++<]>.[++>---<]>+.[->+++<]>.<
<<<<<<[-]<[-]]<<<<<<<<>>>>>>>>>[>--[-->+++<]>.<<[-]]<<<<<<<<<>>>>>>>>>>[-]>[-
]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]><<<<<<<<<<<<<<<<<<<<<]--[-->+++<]>.>+++++++
+++.

Self Hosting
============

$ ./bf < bf2c.bf > bf.c
$ rm bf
$ gcc bf.c -o bf
$ ./bf < bf2c.bf > bf2.c
$ diff bf.c bf2.c
$

Runs Hello World
================

$ cat hello.bf
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
$ ./bf < hello.bf > hello.c
$ gcc hello.c && ./a.out
Hello World!

Runs Quine.. almost (newline issue)
===================================

$ ./bf < quine.bf > quine.c
$ gcc quine.c && ./a.out > quine.txt
$ echo >> quine.txt
$ diff quine.bf quine.txt
$

Name: Anonymous 2014-04-30 15:06

>>2
it looks like this
...;*p++;*p++;*p=getch();while(*p){...

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List