use crate::utils::location::Location;
#[derive(Debug, Clone, PartialEq)]
pub enum TokenType {
Equals,
NotEquals,
LessThan,
GreaterThan,
LessThanEquals,
GreaterThanEquals,
Or,
And,
Assign,
LParen,
RParen,
LBrace,
RBrace,
SemiColon,
Colon,
DoubleColon,
Period,
PeriodTriple,
Comma,
LBracket,
RBracket,
Ampersand,
Star,
Add, Minus, Divide, Multiply, Modulo, Not,
True,
False,
VarKeyword,
IfKeyword,
ElseKeyword,
WhileKeyword,
FnKeyword,
PubKeyword,
ReturnKeyword,
ExternKeyword,
ForKeyword,
InKeyword,
UseKeyword,
StructKeyword,
SizeOfKeyword,
TypeOfKeyword,
BreakKeyword,
ConstKeyword,
AsKeyword,
ElseIfKeyword,
Identifier,
IntLiteral,
CharLiteral,
StringLiteral,
Niltoken,
}
#[derive(Clone, Debug)]
pub struct Token {
pub ttype: TokenType,
pub location: Location,
pub value: String,
}
impl std::fmt::Display for Token {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Token {{ Type: {:?}, Location: ({}, {}), Value: {} }}",
self.ttype, self.location.line, self.location.col, self.value
)
}
}