added repl, eof token, and a parser with a AST producer
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user