update NOTICE
[nit.git] / contrib / brainfuck / README.md
1 # Brainfuck
2
3 Brainfuck is as its name implies a simple Brainfuck interpreter written in Nit.
4
5 It has almost as much purposes as the language itself, except it provides a good example for Nit programs that work while being concise.
6
7 [Specification](http://www.muppetlabs.com/~breadbox/bf/)
8
9 The language is designed to need only a few things :
10
11 * One instruction pointer to the current instruction
12 * One array of Bytes for all manipulations of data
13 * One data pointer to select where to write/read data
14
15 Brainfuck a small instruction set, only eight instructions :
16
17 * `>`: Increments the data pointer
18 * `<`: Decrements the data pointer
19 * `+`: Increments the byte in the current cell
20 * `-`: Decrements the byte in the current cell
21 * `[`: If the current cell's value is 0, jumps to the matching `]`
22 * `]`: If the current cell's value is non-zero, jumps to the matching `[`
23 * `.`: Writes the current cell's value to stdout
24 * `,`: Reads a char from stdin and stores it in the current cell
25
26 ## How to use
27
28 First, compile the interpreter with the Nit compiler/interpreter, and launch the program on a brainfuck source file for interpretation.
29
30 Example:
31 ~~~
32 nitc ./brainfuck.nit
33 ./brainfuck ./examples/hello.bf
34 ~~~