handle error case in lexing
This commit is contained in:
parent
521862bc97
commit
242cd7857f
@ -48,6 +48,7 @@ impl<'a> Iterator for Lexer<'a> {
|
|||||||
s.push_str(&n);
|
s.push_str(&n);
|
||||||
TokenKind::Number(s)
|
TokenKind::Number(s)
|
||||||
}
|
}
|
||||||
|
e @ TokenKind::Error(..) => e,
|
||||||
_ => unsafe { std::hint::unreachable_unchecked() },
|
_ => unsafe { std::hint::unreachable_unchecked() },
|
||||||
},
|
},
|
||||||
'a'..='z' | 'A'..='Z' | '_' | '-' => match self.lex_ident() {
|
'a'..='z' | 'A'..='Z' | '_' | '-' => match self.lex_ident() {
|
||||||
@ -62,6 +63,7 @@ impl<'a> Iterator for Lexer<'a> {
|
|||||||
TokenKind::Ident(s)
|
TokenKind::Ident(s)
|
||||||
}
|
}
|
||||||
TokenKind::Symbol(Symbol::Minus) => TokenKind::Ident(String::from("--")),
|
TokenKind::Symbol(Symbol::Minus) => TokenKind::Ident(String::from("--")),
|
||||||
|
e @ TokenKind::Error(..) => e,
|
||||||
_ => unsafe { std::hint::unreachable_unchecked() },
|
_ => unsafe { std::hint::unreachable_unchecked() },
|
||||||
},
|
},
|
||||||
_ => TokenKind::Symbol(Symbol::Minus),
|
_ => TokenKind::Symbol(Symbol::Minus),
|
||||||
@ -79,6 +81,7 @@ impl<'a> Iterator for Lexer<'a> {
|
|||||||
s.push_str(&n);
|
s.push_str(&n);
|
||||||
TokenKind::Number(s)
|
TokenKind::Number(s)
|
||||||
}
|
}
|
||||||
|
e @ TokenKind::Error(..) => e,
|
||||||
_ => unsafe { std::hint::unreachable_unchecked() },
|
_ => unsafe { std::hint::unreachable_unchecked() },
|
||||||
},
|
},
|
||||||
_ => TokenKind::Symbol(Symbol::Period),
|
_ => TokenKind::Symbol(Symbol::Period),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user