mute/src/main.rs
Roman Godmaire c38576b667 refactor: extract env, macros, error, and remove expression
Rather than using expressions, we can instead just parse into nodes then
work with those instead.  Everything in this language is an Expression,
so there's no reason to differentiate between nodes and expressions.
2024-05-04 16:40:02 -04:00

38 lines
799 B
Rust

use std::io::{self, Write};
mod env;
mod error;
mod evaluator;
mod macros;
mod node;
mod parser;
fn main() {
let env = env::Environment::new();
let mut input = String::new();
println!("Mute -- 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 ast = parser::parse_str(&input).unwrap();
let res = evaluator::eval(&env, ast);
match res {
Ok(expressions) => expressions.into_iter().for_each(|expr| println!("{expr}")),
Err(err) => println!("{}", err),
}
input.clear();
}
}