diff --git a/libconlang/examples/interpret.rs b/libconlang/examples/interpret.rs index 5c2f732..d592976 100644 --- a/libconlang/examples/interpret.rs +++ b/libconlang/examples/interpret.rs @@ -83,8 +83,12 @@ fn take_stdin() -> Result<(), Box> { } fn run_file(file: &str, path: Option<&Path>) -> Result<(), Box> { + let mut interpreter = Interpreter::new(); match Parser::from(Lexer::new(file)).parse() { - Ok(ast) => Interpreter::new().interpret(&ast)?, + Ok(ast) => { + interpreter.interpret(&ast)?; + println!("{}", interpreter.call("main", &[])?) + }, Err(e) if e.start().is_some() => print!("{:?}:{}", path.unwrap_or(Path::new("-")), e), Err(e) => print!("{e}"), }