/// The type of a token. May also contain its litteral value. #[derive(Clone, PartialEq, Debug)] pub enum TokenType { LeftParen, RightParen, LeftBrace, RightBrace, Address, Comma, Dot, Minus, Plus, Semicolon, Slash, Star, Bang, BangEqual, Equal, EqualEqual, Greater, GreaterEqual, Less, LessEqual, Identifier(String), String(String), Number(f64), And, Break, Class, Continue, Else, False, Fun, For, If, Nil, Or, Print, Return, Static, Super, This, True, Var, While, Eof, } /// Full information about a token. #[derive(Clone, Debug)] pub struct Token { pub token_type: TokenType, pub lexeme: String, pub line: usize, } impl Token { /// Check whether a token is an identifier. pub fn is_identifier(&self) -> bool { matches!(self.token_type, TokenType::Identifier(_)) } }