29 lines
584 B
Rust
29 lines
584 B
Rust
use std::process;
|
|
|
|
use crate::parser::{self, Parser};
|
|
|
|
pub fn repl() {
|
|
// Read-Eval-Print Loop
|
|
use std::io::{self, Write};
|
|
|
|
println!("Welcome to the Riv Lang REPL! Type 'exit' to quit.");
|
|
|
|
loop {
|
|
print!("> ");
|
|
io::stdout().flush().unwrap();
|
|
|
|
let mut input = String::new();
|
|
io::stdin().read_line(&mut input).unwrap();
|
|
|
|
let input = input.trim().to_string();
|
|
|
|
if input == "exit" {
|
|
process::exit(0);
|
|
}
|
|
|
|
let program = Parser::new(input).produce_ast();
|
|
|
|
println!("{:#?}", program);
|
|
}
|
|
}
|