[fine] Starting on pattern matching, make patterns explicit

This commit is contained in:
John Doty 2024-02-04 07:47:16 -08:00
parent f00b9e22e7
commit deed9d9a45
4 changed files with 178 additions and 50 deletions

View file

@ -50,6 +50,7 @@ pub enum TokenKind {
In,
Is,
Let,
Match,
New,
Or,
Return,
@ -307,6 +308,11 @@ impl<'a> Tokens<'a> {
return TokenKind::Let;
}
}
'm' => {
if ident == "match" {
return TokenKind::Match;
}
}
'n' => {
if ident == "new" {
return TokenKind::New;
@ -597,7 +603,13 @@ mod tests {
(58, New, "new")
);
test_tokens!(more_more_keywords, "in is", (0, In, "in"), (3, Is, "is"));
test_tokens!(
more_more_keywords,
"in is match",
(0, In, "in"),
(3, Is, "is"),
(6, Match, "match")
);
test_tokens!(
strings,