[parser] Fill in some framing comments; pass lexer errors out directly

This commit is contained in:
Eryn Wells 2018-08-24 08:00:33 -07:00
parent d9abd033e7
commit d13396bb5d

View file

@ -44,18 +44,28 @@ 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 out: Option<Self::Item> = None;
let mut result: Option<NodeParseResult> = None; let mut result: Option<NodeParseResult> = None;
loop { loop {
match self.input.next() { match self.input.next() {
Some(Ok(ref lex)) => { Some(Ok(ref lex)) => {
// TODO: Valid Lex from our input. Hand it off to the
// current parser and process the result.
}, },
Some(Err(ref error)) => { Some(Err(ref error)) => {
// TODO: Lexer error. Throw it up and out.
out = Some(Err(ParseError::LexerError { msg: error.msg().to_string() }));
}, },
None => break None => {
// TODO: We didn't get a Lex from the input. If there's any
// parse result waiting around, clean it up and return it or
// return an error.
break;
}
} }
} }
assert_eq!(self.parsers.len(), 0); assert_eq!(self.parsers.len(), 0);
None out
} }
} }