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