#use wml::tmpl::main title="BrainFuck for Emacs" PAGE=programming SUBPAGE=bf

<H1>What the Fuck is BrainFuck?</h1>
<P>BrainFuck is a turing complete programming language.
It consists only of 8 different operators, which are represented
by single characters each.</p>
<p>These operations manipulate a memory pointer, which points into a
memory area of 30000 cells, each initially initialised to zero.</p>
<table>
<caption>List of all BrainFuck operators</caption>
<tr><th>Character</th><th>Description</th></tr>
<tr><td align=center><font size=+1>+</font></td>
    <td>Add 1 to the memory cell the pointer currently points to</td></tr>
<tr><td align=center><font size=+1>-</font></td>
    <td>Subtract 1 from the cell currently pointed to</td></tr>
<tr><td align=center><font size=+1>&gt;</font></td>
    <td>Increase the pointer, pointing to the next memory cell</td></tr>
<tr><td align=center><font size=+1>&lt;</font></td>
    <td>Decrease the pointer by 1 memory cell</td></tr>
<tr><td align=center><font size=+1>.</font></td>
    <td>Output value of the current cell as a byte</td></tr>
<tr><td align=center><font size=+1>,</font></td>
    <td>Read input and set the current cell</td></tr>
<tr><td align=center><font size=+1>[</font></td>
    <td>If current cell is zero, goto end of loop, else continue</td></tr>
<tr><td align=center><font size=+1>]</font></td>
    <td>Goto beginning of loop</td></tr>
</table>
<h2>An Emacs Lisp Implementation</h2>
<P><A href="bf.el">bf.el</A> is an implementation of the BrainFuck
programming language for GNU <a href="emacs.html">Emacs</a>.  It implements an
interpreter for BrainFuck, as well as a compiler which
can compile BrainFuck code to native Emacs Lisp byte code.</p>
<p>bf.el uses a <A href="http://home.planet.nl/~faase009/Ha_bf_inter.html">BF
interpreter written in BF</A> to test correctness.  The included test case can
take very long, depending on the hardware you are running it on, but it should
pass without failure.</p>


