I'm trying to learn a bit about Nim and so decided to write a Brainfuck interpreter as a learning exercise. The trouble is there's a bug that causes my interpreter to crash on the "Hello World!" example from Wikipedia:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
I've been trying to fix it for days but I'm completely stumped as to what's causing it and was hoping somebody smarter than me could maybe figure it out. Here's a link to my code:
https://gist.github.com/drguildo/212d14b724e85c833efd6e524290276d
A hint as to why it crashes is here.
You're using an int, when you should be using a uint8 for your dataPointer variable.
Also, this python example can help you precompute a jump table so you don't have to iterate over every instruction every time.
If you are still stuck and want the answer (plus some helpful comments), here is a working example from your code