pub struct Token {
pub type: Type,
pub lexeme: String,
pub literal: Option<Literal>,
pub location: Location,
}
Expand description
Represents a token in the language.
Fields§
§type: Type
Type of the token.
lexeme: String
String representation of the token.
literal: Option<Literal>
Literal value of the token (if any).
location: Location
Location of the token in the source code.
Implementations§
Trait Implementations§
Source§impl Hash for Token
This is required for the HashMap
to work for Interpreter::locals
.
Since no two tokens can have the same type, lexeme, and location, we can use them as the key for
the HashMap
.
impl Hash for Token
This is required for the HashMap
to work for Interpreter::locals
.
Since no two tokens can have the same type, lexeme, and location, we can use them as the key for
the HashMap
.
impl Eq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more