[lexer] Bring over the REPL from the parser
This commit is contained in:
parent
a23b917785
commit
1304e04808
1 changed files with 19 additions and 3 deletions
|
|
@ -4,11 +4,27 @@
|
||||||
|
|
||||||
extern crate sibillexer;
|
extern crate sibillexer;
|
||||||
|
|
||||||
|
use std::io::prelude::*;
|
||||||
|
use std::io;
|
||||||
use sibillexer::Lexer;
|
use sibillexer::Lexer;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let lexer = Lexer::new("(ab (cd) ef)".chars());
|
loop {
|
||||||
for tok in lexer {
|
// Print a prompt.
|
||||||
println!("found {:?}", tok.unwrap());
|
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!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue