pub struct Token {
pub token_type: TokenType,
pub lexeme: String,
pub line: usize,
pub column: usize,
}Expand description
Represents a token with its type, value, and position in source
Fields§
§token_type: TokenType§lexeme: String§line: usize§column: usizeImplementations§
Source§impl Token
impl Token
Sourcepub fn new(
token_type: TokenType,
lexeme: String,
line: usize,
column: usize,
) -> Self
pub fn new( token_type: TokenType, lexeme: String, line: usize, column: usize, ) -> Self
Create a new token
Sourcepub fn location(&self) -> SourceLocation
pub fn location(&self) -> SourceLocation
Get the source location of this token
Sourcepub fn is_keyword(&self) -> bool
pub fn is_keyword(&self) -> bool
Check if token is a keyword
Sourcepub fn is_operator(&self) -> bool
pub fn is_operator(&self) -> bool
Check if token is an operator
Sourcepub fn is_delimiter(&self) -> bool
pub fn is_delimiter(&self) -> bool
Check if token is a delimiter
Trait Implementations§
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