36 lines
625 B
Rust
36 lines
625 B
Rust
|
use std::io::{self, Write};
|
||
|
|
||
|
fn main() {
|
||
|
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 ast = read(&input);
|
||
|
let res = eval(&ast);
|
||
|
|
||
|
println!("{res}");
|
||
|
|
||
|
input.clear();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn read(input: &str) -> String {
|
||
|
input.to_owned()
|
||
|
}
|
||
|
|
||
|
fn eval(input: &str) -> String {
|
||
|
input.to_owned()
|
||
|
}
|