1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//! The Token struct holds the tokens that are generated by the Lexer. //! The Token struct maintains the position where the token was generated and the value of the token. //! Using an enum for the values increases the readibility of the code. use super::token_kind::TokenKind; #[derive(Debug)] pub struct Token { pub kind: TokenKind, pub pos: usize, } impl Token { /// Constructs a new token with the given value and position. /// /// # Arguments /// `kind` - The value of this Token. /// `pos` - The position where this Token was created. pub fn new(kind: TokenKind, pos: usize) -> Token { Token { kind, pos } } }