Hello everyone! It has been a while since last programming challenge, it's time for another one! This week's goal would be to build your own interpreter. Interpreter is program that receives input...
Hello everyone! It has been a while since last programming challenge, it's time for another one!
This week's goal would be to build your own interpreter.
Interpreter is program that receives input and executes it. For example Python is interpreted language, meaning you are actually writing instructions for the interpreter, which does the magic.
Probably the easiest interpereter to write is Brainfuck interpreter. If someone here doesn't know, Brainfuck is programming language, which contains following instructions:
,.<>-+. Other characters are ignored. It has memory in form of array of integers. At the start, pointer that points to one specific memory cell points to cell 0. We can use
<to move pointer to left (decrement) and
>to move pointer to right (increment).
.can be used to print value of cell the pointer is currently pointing to (ascii).
,can be used to read one character from stdin and write it to memory.
[is beggining of loop and
]is end of loop. Loops can be nested. Loop is terminated when we reach
]character and current value in memory is equal to 0.
-can be used to decrement value in memory by 1 and
+can be used to increment value in memory by 1. Here's Hello World:
++++++++++[>+++++++>++++++++++>+++>+<<<< -]>++.>+.+++++++..+++.>++.<<++++++++++++ +++.>.+++.------.--------.>+.>.
People with nothing to do today can attemp to make an interpreter for the Taxi programming language.
You can even make your own language! There are no limits for this challenge.23 votes