Giter VIP home page Giter VIP logo

bf2d's Introduction

bf2d is a Brainfuck to D conversion tool written in the D programming
language. I wrote it on a boring Sunday evening in 2005 and ended up
winning the first obfuscated D coding contest.


Original README:

Brainfuck is a minimalistic Turing-complete programming language,
designed by Urban Müller around 1993. A Brainfuck program has an
implicit pointer, which is free to move around and manipulate an array
of 30000 integers, initially all set to zero. The pointer initially
points to the leftmost element of this array.  There are eight
Brainfuck instructions, represented by a single character
respectively.
>       move the pointer to the next element to the right
<       move the pointer to the next element to the left
+       increment the value at the pointer.
-       decrement the value at the pointer.
.       read the value at the pointer and write it to the standard output.
,       read a character from the standard input and store its value in the
element at the pointer.
[       pass control to the next instruction following the matching ] if
the value at the pointer is zero.
]       pass control to the next instruction following the matching [ if
the value at the pointer is zero.
Other characters in a Brainfuck program are considered as comment and
ignored by a compiler or interpreter.

Here is a simple "Hello D!" program in Brainfuck:
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>+++++++
+[<++++>-]<.>+++++++[<+++++>-]<+.>>++++++++[<++++>-]<+.>++++++++++.

Don't have a Brainfuck compiler?  Fret not.  Run BF2D to convert your
BF programs to clean D source code on the fly!  It's also a perfect
tool for D neophytes who have a BF background.

Build instruction (Win32): dmd bf2d.d
Usage: bf2d < %brainfuck-source% > %converted-D-source%

Some more BF programs for readers to play with:

,+[-.,+]
an echo program that copies input to output

>,+[->,+]<[.<]
reverse the input

>>>+>>>>>+>>+>>+[<<],+[--[-[-[-[-[-[-[-[<+>-[>+<-[>-<-[-[-[<++
[<++++++>-]<[>>[-<]<[>]<-]>>[<+>-[<->[-]]]]]]]]]]]]]]]]<[-<<[-
]+>]<<[>>>>>>+<<<<<<-]>[>]>>>>>>>+>[<+[>+++++++++<-[>-<-]++>[<
+++++++>-[<->-]+[+>>>>>>]]<[>+<-]>[>>>>>++>[-]]+<]>[-<<<<<<]>>
>>],+]+<++>>>[[+++++>>>>>>]<+>+[[<++++++++>-]<.<<<<<]>>>>>>>>]
yet another word count program, slightly modified from
Daniel B Cristofani's version (http://www.hevanet.com/cristofd/brainfuck/)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.