From 374017d5e354ee9573a03afa51c2dcc7bafabe16 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 29 Oct 2023 23:48:38 -0500 Subject: [PATCH] examples/interpret: Call `main` if loading from file --- libconlang/examples/interpret.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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}"), }