Token - is_litteral() method
This commit is contained in:
parent
984ba5f600
commit
ccc6fe0320
1 changed files with 14 additions and 0 deletions
|
@ -53,3 +53,17 @@ pub struct Token {
|
|||
pub lexeme: String,
|
||||
pub line: usize,
|
||||
}
|
||||
|
||||
impl Token {
|
||||
/// Check whether a token corresponds to a litteral value.
|
||||
pub fn is_litteral(&self) -> bool {
|
||||
match self.token_type {
|
||||
TokenType::True
|
||||
| TokenType::False
|
||||
| TokenType::Nil
|
||||
| TokenType::String(_)
|
||||
| TokenType::Number(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue