diff --git a/SLS_Rust/sls/src/interpreter.rs b/SLS_Rust/sls/src/interpreter.rs index 4842980..bdafc86 100644 --- a/SLS_Rust/sls/src/interpreter.rs +++ b/SLS_Rust/sls/src/interpreter.rs @@ -124,7 +124,7 @@ impl InterpreterState { } pub fn stack_top(&self) -> Option<&StackValue> { - self.stack.get(0) + self.stack.get(self.stack.len() - 1) } } diff --git a/SLS_Rust/sls/src/repl.rs b/SLS_Rust/sls/src/repl.rs index 1bfa9be..dd0718a 100644 --- a/SLS_Rust/sls/src/repl.rs +++ b/SLS_Rust/sls/src/repl.rs @@ -67,7 +67,8 @@ pub fn repl() -> i32 { LexResult::Ok(tokens) => { for token in tokens { if !interpreter.execute(token) { - return 1; + println!("A runtime error occured!"); + break; } }