Brainfuck
syntax
| <program> | = | ε |
| | | <program>+ | |
| | | <program>- | |
| | | <program>< | |
| | | <program>> | |
| | | <program>[ | |
| | | <program>] | |
| | | <program>. | |
| | | <program>, | |
+><- is generated
ε,
+,
+>,
+><,
+><-.
semantics
data
| 0 | 0 | 0 | 0 | 0 | ||
| ↑ |
↑) remembers which.
instruction
| + | [ | > | + | < | - | ] | . |
| ↑ |
runtime
| data | instruction | |
|---|---|---|
+ | the data under the data pointer is incremented | the instruction pointer advances |
- | the data under the data pointer is decremented | the instruction pointer advances |
< | the data pointer shifts to the left | the instruction pointer advances |
> | the data pointer shift to the right | the instruction pointer advances |
[ | if the data under the data pointer is zero | the instruction pointer advances past its matching ] |
] | the instruction pointer advances back to its matching [ |
|
. | the data under the data pointer is output | the instruction pointer advances |
+ | the data under the data pointer takes an input | the instruction pointer advances |
theory
implementation notes
syntax
+++[~*~a commented embedded in program text~*~>++>+<<-]
[ ].
semantics
- picking a useful format for the input/output instructions
,/., e.g. ASCII. - memory cells using underlying machine memory cells, e.g. in place of unbounded integers, an 8-bit computer using 8-bit cells with wrapping arithmetic.
- data pointer as machine memory cell or machine pointer, e.g. a (neccessarily finite) data tape with counted cells,
>incrementing and<decrementing the pointer. - exceptions or runtime errors, e.g. if
<or>run outside a finite data memory, or if-underflows unsigned memory cells.