Removed various bits of unused code

This commit is contained in:
Emmanuel BENOîT 2023-01-11 07:20:29 +01:00
parent 16151bd326
commit ecc8f2ec8b
2 changed files with 2 additions and 30 deletions

View file

@ -58,28 +58,8 @@ pub struct Token {
}
impl Token {
/// Check whether a token corresponds to a litteral value.
pub fn is_litteral(&self) -> bool {
matches!(
self.token_type,
TokenType::True
| TokenType::False
| TokenType::Nil
| TokenType::String(_)
| TokenType::Number(_)
)
}
/// Check whether a token is an identifier.
pub fn is_identifier(&self) -> bool {
matches!(self.token_type, TokenType::Identifier(_))
}
/// Get the name from an identifier token, returning an error otherwise.
pub fn as_identifier(&self) -> Result<&str, &'static str> {
match &self.token_type {
TokenType::Identifier(name) => Ok(name),
_ => Err("token is not an identifier"),
}
}
}