diff --git a/lexer/src/main.rs b/lexer/src/main.rs index e177f98..366ef92 100644 --- a/lexer/src/main.rs +++ b/lexer/src/main.rs @@ -4,11 +4,27 @@ extern crate sibillexer; +use std::io::prelude::*; +use std::io; use sibillexer::Lexer; fn main() { - let lexer = Lexer::new("(ab (cd) ef)".chars()); - for tok in lexer { - println!("found {:?}", tok.unwrap()); + loop { + // Print a prompt. + print!("> "); + io::stdout().flush().ok().expect("couldn't flush"); + + // Read a line from stdin. + let mut input = String::new(); + io::stdin().read_line(&mut input).unwrap(); + + // Create a lexer and parser and process the input. + let lexer = Lexer::new(input.chars()); + + // Print the parser's output. + for thing in lexer { + println!("{:?}", thing); + } + println!(); } }