Elixir as a parsing tool: writing a Brainfuck interpreter, part two

This is the second in a series of articles on building a brainfuck interpreter in Elixir

In the first part we built a minimal brainfuck interpreter that can already run some basic program.
For example


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
# prints A

,-.
# prints the ASCII character preceding the one taken as input
# in "B" -> out "A" 

But honestly we can’t do anything more with it.

The first missing feature is memory management. We have implemented the functions that move the pointer to memory cells left and right, but we’re still stuck with a non expanding memory tape of one cell only.

Let’s implement memory auto expansion, turns out it is gonna be very easy.

Continue reading “Elixir as a parsing tool: writing a Brainfuck interpreter, part two”