Files
rust-mal/src/main.rs
teo3300 54d196582f Oneline multi expression
Multiple expressions can be evaluated on a single line

Signed-off-by: teo3300 <matteo.rogora@live.it>
2023-06-07 14:41:12 +02:00

48 lines
1.1 KiB
Rust

// io lib to read input and print output
use std::io::{self, Write};
mod printer;
mod reader;
mod types;
mod step1_read_print;
use step1_read_print::rep;
fn main() -> io::Result<()> {
loop {
let mut input = String::new();
loop {
print!("user> ");
// Flush the prompt to appear before command
let _ = io::stdout().flush();
// Read line to compose program inpug
let mut line = String::new();
io::stdin().read_line(&mut line)?;
if line == "\n" {
break;
}
input.push_str(&line);
// Perform rep on whole available input
match rep(&input) {
Ok(output) => {
for el in output {
println!("{}", el);
}
}
Err(err) => {
if line == "\n" {
println!("ERROR: {}", err);
} else {
continue;
}
}
}
break;
}
}
}