Crates.io | rustration |
lib.rs | rustration |
version | 0.1.0 |
source | src |
created_at | 2017-01-13 10:25:21.284256 |
updated_at | 2017-01-13 10:25:21.284256 |
description | A toy Brainfuck compiler/interpreter |
homepage | |
repository | https://github.com/dnseitz/rustration |
max_upload_size | |
id | 8040 |
size | 59,814 |
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
Brainfuck is an esoteric programming language invented by Urban Muller in 1993. The language
operates on an array of memory cells, also called a tape. Every cell is intialized to 0. There
is a pointer that intially points to the first memory cell, and several commands are used to
manipulate the pointer and the data on the tape. The set of commands are >
, <
, +
, -
,
[
, ]
, .
, and ,
.
<
and >
move the data pointer left and right respectively. +
and -
increment and
decrement the data in the cell being pointed at. [
and ]
act as a looping mechanism for the
language. A [
command means jump past the matching ]
if the cell under the data pointer is
0. A ]
command means jump back to the matching [
if the cell under the data pointer is not
0. This looping construct is similar to a while loop in a C-like language. A C representation
would be something like:
while *data != 0 {
}
The ,
and .
commands act as input and output respectively. ,
inputs a character and
stores it at the data pointer, .
outputs the character under the data pointer.
All other characters are considered comments and are ignored.