[lexer] Bring over the REPL from the parser

This commit is contained in:
Eryn Wells 2018-08-26 13:45:52 -07:00
parent a23b917785
commit 1304e04808

View file

@ -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!();
}
}