Alpha Chen 2 years ago
parent 5d0bd0d785
commit 5e38b1ca95
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -194,21 +194,17 @@ impl<'a> Scanner<'a> {
's' if &self.source[1..self.current] == "uper".as_bytes() => TokenKind::Super, 's' if &self.source[1..self.current] == "uper".as_bytes() => TokenKind::Super,
'v' if &self.source[1..self.current] == "ar".as_bytes() => TokenKind::Var, 'v' if &self.source[1..self.current] == "ar".as_bytes() => TokenKind::Var,
'w' if &self.source[1..self.current] == "hile".as_bytes() => TokenKind::While, 'w' if &self.source[1..self.current] == "hile".as_bytes() => TokenKind::While,
'f' if self.current > 1 => { 'f' if self.current > 1 => match self.source[1] as char {
match self.source[1] as char {
'a' if &self.source[2..self.current] == "lse".as_bytes() => TokenKind::False, 'a' if &self.source[2..self.current] == "lse".as_bytes() => TokenKind::False,
'o' if &self.source[2..self.current] == "r".as_bytes() => TokenKind::For, 'o' if &self.source[2..self.current] == "r".as_bytes() => TokenKind::For,
'u' if &self.source[2..self.current] == "n".as_bytes() => TokenKind::Fun, 'u' if &self.source[2..self.current] == "n".as_bytes() => TokenKind::Fun,
_ => TokenKind::Identifier, _ => TokenKind::Identifier,
}
}, },
't' if self.current > 1 => { 't' if self.current > 1 => match self.source[1] as char {
match self.source[1] as char {
'h' if &self.source[2..self.current] == "is".as_bytes() => TokenKind::This, 'h' if &self.source[2..self.current] == "is".as_bytes() => TokenKind::This,
'r' if &self.source[2..self.current] == "ue".as_bytes() => TokenKind::True, 'r' if &self.source[2..self.current] == "ue".as_bytes() => TokenKind::True,
_ => TokenKind::Identifier, _ => TokenKind::Identifier,
} },
}
_ => TokenKind::Identifier, _ => TokenKind::Identifier,
} }
} }

Loading…
Cancel
Save