You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
885 B
41 lines
885 B
mod execute;
|
|
mod parse;
|
|
mod prompt;
|
|
|
|
use execute::interpret;
|
|
use rustyline::error::ReadlineError;
|
|
use rustyline::{Editor, Result};
|
|
|
|
use crate::prompt::Prompt;
|
|
|
|
fn main() -> Result<()> {
|
|
let mut rl = Editor::<()>::new()?;
|
|
|
|
let mut prompt = Prompt::new();
|
|
|
|
loop {
|
|
let readline = rl.readline(&prompt.get_prompt());
|
|
|
|
match readline {
|
|
Ok(line) => {
|
|
if let Err(err) = interpret(&line) {
|
|
println!("{}", err);
|
|
}
|
|
}
|
|
Err(ReadlineError::Interrupted) => {
|
|
println!("CTRL-C");
|
|
break;
|
|
}
|
|
Err(ReadlineError::Eof) => {
|
|
println!("CTRL-D");
|
|
break;
|
|
}
|
|
Err(err) => {
|
|
println!("Error: {:?}", err);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|