A peekable lexer
Use the chars() iterator on &str, with the Peekable wrapper on Iterators, to iterate the input, rather than needing to hold the whole input and do iteration by indexes.
This commit is contained in:
parent
a4282e7760
commit
c5b769ff45
3 changed files with 93 additions and 1 deletions
14
lexer/src/main.rs
Normal file
14
lexer/src/main.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* lexer/src/main.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
extern crate sibillexer;
|
||||
|
||||
use sibillexer::Lexer;
|
||||
|
||||
fn main() {
|
||||
let lexer = Lexer::new("(ab (cd) ef)".chars());
|
||||
for tok in lexer {
|
||||
println!("found {:?}", tok.unwrap());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue