pull interpreter value out into its own file

This commit is contained in:
Sebastian Hugentobler 2025-02-11 14:09:52 +01:00
parent 6440819ff2
commit 15b331f447
3 changed files with 48 additions and 30 deletions

View file

@ -27,6 +27,7 @@ pub mod tokenizer {
pub mod string;
pub mod whitespace;
}
pub mod value;
/// Read the source code in a file and scan it to tokens.
pub fn compile(source: &Path) -> Result<(), io::Error> {
@ -57,7 +58,7 @@ fn run(input: &str) {
let tokens = scanner::tokenize(input);
match parser::generate_ast(tokens) {
Ok(ast) => match interpreter::evaluate(ast) {
Ok(value) => info!("{value:?}"),
Ok(value) => println!("{value}"),
Err(e) => error!("{e}"),
},
Err(e) => error!("{e}"),