mute/src/main.rs
Roman Godmaire 75591cac9a Mal step 3
2023-09-19 10:15:40 -04:00

35 lines
736 B
Rust

use std::io::{self, Write};
mod evaluator;
mod lexer;
mod parser;
fn main() {
let env = evaluator::core_environment();
let mut input = String::new();
println!("MAL -- REPL");
loop {
print!("> ");
io::stdout().flush().expect("failed to write to stdout");
let bytes_read = io::stdin()
.read_line(&mut input)
.expect("failed to read from stdin");
if bytes_read == 0 {
break;
}
let tokens = lexer::read(&input).unwrap();
let ast = parser::parse(tokens).unwrap();
let res = evaluator::eval(env.clone(), ast).unwrap();
for expr in res {
println!("{expr}")
}
input.clear();
}
}