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