mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 15:27:45 +03:00
Have the repl loop
This commit is contained in:
parent
a99a339672
commit
c9ef2deb80
@ -38,26 +38,38 @@ pub fn main() -> io::Result<()> {
|
||||
use std::io::BufRead;
|
||||
|
||||
println!(
|
||||
"\n The rockin’ \u{001b}[36mroc repl\u{001b}[0m\n\u{001b}[35m────────────────────────\n"
|
||||
"\n The rockin’ \u{001b}[36mroc repl\u{001b}[0m\n\u{001b}[35m────────────────────────\u{001b}[0m\n\nEnter :help for help, or :exit to exit."
|
||||
);
|
||||
|
||||
// Loop
|
||||
|
||||
print!("\u{001b}[36m▶\u{001b}[0m ");
|
||||
loop {
|
||||
print!("\n\u{001b}[36m▶\u{001b}[0m ");
|
||||
|
||||
io::stdout().flush().unwrap();
|
||||
io::stdout().flush().unwrap();
|
||||
|
||||
let stdin = io::stdin();
|
||||
let line = stdin
|
||||
.lock()
|
||||
.lines()
|
||||
.next()
|
||||
.expect("there was no next line")
|
||||
.expect("the line could not be read");
|
||||
let stdin = io::stdin();
|
||||
let line = stdin
|
||||
.lock()
|
||||
.lines()
|
||||
.next()
|
||||
.expect("there was no next line")
|
||||
.expect("the line could not be read");
|
||||
|
||||
let (answer, answer_type) = gen(line.as_str(), Triple::host(), OptLevel::Normal);
|
||||
match line.trim() {
|
||||
":help" => {
|
||||
println!("Use :exit to exit.");
|
||||
}
|
||||
":exit" => {
|
||||
break;
|
||||
}
|
||||
line => {
|
||||
let (answer, answer_type) = gen(line, Triple::host(), OptLevel::Normal);
|
||||
|
||||
println!("\n{} \u{001b}[35m:\u{001b}[0m {}", answer, answer_type);
|
||||
println!("\n{} \u{001b}[35m:\u{001b}[0m {}", answer, answer_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user