[fine] Use keyword

This commit is contained in:
John Doty 2024-01-03 05:45:12 -08:00
parent d73f77cf00
commit 93cc30ba9b

View file

@ -44,6 +44,7 @@ pub enum TokenKind {
Select,
This,
True,
Use,
While,
Yield,
@ -326,6 +327,11 @@ impl<'a> Tokens<'a> {
return TokenKind::True;
}
}
'u' => {
if ident == "use" {
return TokenKind::Use;
}
}
'w' => {
if ident == "while" {
return TokenKind::While;
@ -535,7 +541,7 @@ mod tests {
test_tokens!(
more_keywords,
"fun if let print return select this true while truewhile",
"fun if let print return select this true use while truewhile",
(0, Fun, "fun"),
(4, If, "if"),
(7, Let, "let"),
@ -544,8 +550,9 @@ mod tests {
(24, Select, "select"),
(31, This, "this"),
(36, True, "true"),
(41, While, "while"),
(47, Identifier, "truewhile")
(41, Use, "use"),
(45, While, "while"),
(51, Identifier, "truewhile")
);
test_tokens!(