-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|637|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Showcase Home -> Apps and Utilities


 
cthug
Created : 18 June 2009
Edited : 14 July 2009
System : Server Based
Language : Basic

cthug brainfuck compiler

The result of me bored for an hour

ct-brainfuck-v0.22 lastest
Screenshots
I haven't been doin much coding lately, and I was bored so I wrote a simple brainfuck compiler. Outputs c source code. It supports only original eight commands < > + - , . [ ]. Not bad for an hour

Latest Update

* v0.2 - Supports brainfuck++ file i/o (including 0 at EOF), NOT sockets yet, but I will do soon, using SDL_net. Also the output source file is now formatted, nested tabulation.
* v0.21 - Minor output formatting bug fix.
* v0.22 - Added @ instruction, exits program, and some more examples.

Old versions:
ct-bf v0.1beta
ct-bf v0.2
ct-bf v0.22

 

Comments


Thursday, 18 June 2009, 19:46
Agent
déjà vu

Shouldn't your error conditions exit with EXIT_FAILURE ?
Thursday, 18 June 2009, 20:50
cthug
yeah, doesn't really matter, I will change. I am making it support brainfuck++, so that can be a minor change
Friday, 19 June 2009, 02:09
Afr0
Maybe one can write an MSN client in Brainfuck now!
Friday, 19 June 2009, 03:08
Phoenix
I wouldn't really call it a compiler. It's more like a translator.
Friday, 19 June 2009, 03:22
cthug
What do you call a compiler that translates code into assembly or straight to binary machine code. But yeah it more or less translates brainfuck code to c.

here is an example showing how bf can write to a file

io_write.bf


and again with no comments


Asks for 1 character, then writes it to file called out.txt. Only problem you have to manually create file first. It will fix this.

@ Afr0: have fun making MSN Client

|edit| BTW sorry about no windows executable, I tried compiling with mingw, using wine and got all kinds of linking errors, so I will get on my windows PC and compile |edit|

Good old "Just another brainfuck hacker", with carriage return:

Saturday, 20 June 2009, 06:43
steve_ancell
If I even tried to learn BF, then my brain will be f*****d
Saturday, 20 June 2009, 10:48
CodersRule
I learned it in an hour one night. It's really not that hard. I also wrote a simple addition program, but if you wanted the answer to be any higher than 9, programming it would be like programming a GUI in C++. It's not hard, but it requires lots of testing and lots of bugfixes and its just damn annoying!
Monday, 22 June 2009, 02:56
cthug
brainfuck is good fun, simple, but hard