use std::iter::Peekable; use crate::lexer::Lexer; #[derive(Debug)] pub struct Parser where I: Iterator { lexer: Peekable> } impl Parser where I: Iterator { fn new(scanner: I) -> Parser { Parser { lexer: Lexer::new(scanner).peekable() } } fn parse(self) -> Result<(), String> { self.lexer.for_each(|token| println!("{token:?}",)); Ok(()) } } pub fn parse_string(input: &str) -> Result<(), String> { let scanner = input.chars(); Parser::new(scanner).parse()?; Ok(()) }