Fix lexing bug
This commit is contained in:
parent
44659ec34a
commit
95e5b3062d
@ -36,13 +36,17 @@ pub fn lex<'tokens, 'src: 'tokens>(
|
||||
let mut lexer = Lexer::new(source);
|
||||
let mut tokens = Vec::new();
|
||||
|
||||
while !lexer.is_eof() {
|
||||
loop {
|
||||
let (token, span) = lexer
|
||||
.next_token()
|
||||
.map_err(|error| DustError::Lex { error, source })?;
|
||||
let length = tokens.len();
|
||||
let is_eof = matches!(token, Token::Eof);
|
||||
|
||||
tokens[length] = (token, span);
|
||||
tokens.push((token, span));
|
||||
|
||||
if is_eof {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(tokens)
|
||||
|
Loading…
Reference in New Issue
Block a user