[parser] Working out the structure of this stupid Parser::next()

This commit is contained in:
Eryn Wells 2018-08-23 20:36:41 -07:00
parent 4bade1af4a
commit 2f9c16ff38

View file

@ -15,7 +15,6 @@ use sibillexer::Result as LexerResult;
use sibiltypes::Obj; use sibiltypes::Obj;
use node_parser::{NodeParser, NodeParseResult}; use node_parser::{NodeParser, NodeParseResult};
use program_parser::ProgramParser; use program_parser::ProgramParser;
use sym_parser::SymParser;
/// The output of calling `parse()` on a Parser is one of these Result objects. /// The output of calling `parse()` on a Parser is one of these Result objects.
pub type Result = std::result::Result<Obj, ParseError>; pub type Result = std::result::Result<Obj, ParseError>;
@ -45,13 +44,17 @@ impl<T> Iterator for Parser<T> where T: Iterator<Item=LexerResult> {
type Item = Result; type Item = Result;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let mut lex = self.input.next();
loop { loop {
if let Some(lex) = self.input.next() { match lex {
if let Ok(lex) = lex { Some(ref lex) => {
} else { match lex {
} Ok(ref lex) => {
} else { }
break; Err(error) => {}
}
},
None => break
} }
} }
assert_eq!(self.parsers.len(), 0); assert_eq!(self.parsers.len(), 0);