Interpreter with 900 limit on recursion
reddit.com·7h·
Discuss: r/rust
Flag this post

Hi, I am implementing a small variation of the Monkey programming language in Rust as an exercise (I don’t have much experience in Rust). I have the parser and the lexer, and the first version of an evaluator. However, it seems that no matter what I do, I always get stack overflow with the following program:


let counter = fn (x : int) -> int {

if (x < 900) {

return counter(x + 1);

} else {

return x;

}

};

counter(2);

Here is the code of the evaluator (simplified for this example): https://github.com/tomaz1502/monkey-rs/blob/rec_limit/src/mods/lib/evaluator.rs

I checked and the AST is being correctly generated by the parser. I don’t think I am making to…

Similar Posts

Loading similar posts...