Fix lexer whitespace bug.
This commit is contained in:
parent
1188e2b671
commit
f2f4b0537e
@ -27,8 +27,10 @@ impl<'a> Lexer<'a> {
|
|||||||
let maybe_chunk = self.input.get(self.position..);
|
let maybe_chunk = self.input.get(self.position..);
|
||||||
if maybe_chunk.is_none() {
|
if maybe_chunk.is_none() {
|
||||||
return None;
|
return None;
|
||||||
} else {
|
}
|
||||||
chunk = maybe_chunk.unwrap();
|
chunk = maybe_chunk.unwrap();
|
||||||
|
if chunk.is_empty() {
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,4 +156,11 @@ mod tests {
|
|||||||
assert_next(&mut lexer, TokenKind::End, 3);
|
assert_next(&mut lexer, TokenKind::End, 3);
|
||||||
assert_eq!(lexer.next(), None);
|
assert_eq!(lexer.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn blank_after_last_token_returns_none() {
|
||||||
|
let mut lexer = Lexer::new("fn ");
|
||||||
|
assert_next(&mut lexer, TokenKind::Fn, 2);
|
||||||
|
assert_eq!(lexer.next(), None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user