INDEV: Stack Overvlow with loops
Stack Overflow
The current implementation of loops throws the following error
Code (executed by the interpreter):
+[>+<-]
Error
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
main.rs
file:
mod brainfuck;
use brainfuck::interpreter::*;
fn main() {
let init_ptr: usize = 0;
let init_mem: Vec<u8> = vec![0; 16];
let state: ProgramState = ProgramState::new(init_mem, init_ptr);
let new_state = execute_statements(&vec![
'+',
'[',
'>',
'+',
'<',
'-',
']'],
&state);
dbg!(new_state);
}
It probably comes down to the implementation of the looping system in brainfuck.rs
Edited by Moritz Sokoll