#[allow(dead_code)]
#[derive(Debug, Clone, PartialEq)]
pub enum TokenKind {
Unknown,
Identifier,
Number,
Float,
String,
Char,
Plus,
Minus,
Multiply,
Divide,
Modulo,
Assign,
Equal,
NotEqual,
LessThan,
LessEqual,
GreaterThan,
GreaterEqual,
LeftParen,
RightParen,
LeftBrace,
RightBrace,
LeftBracket,
RightBracket,
Comma,
Semicolon,
Colon,
Dot,
If,
Else,
While,
For,
Function,
Return,
Let,
Const,
Whitespace,
Newline,
Comment,
Eof,
IndexedNumber,
PositiveNumber,
Custom(u32),
}
#[allow(dead_code)]
#[derive(Debug, Clone, PartialEq)]
pub struct Token {
pub kind: TokenKind,
pub text: String,
pub index: usize,
pub row: usize,
pub col: usize,
pub length: usize,
pub indent: usize,
pub tag: isize,
}
#[allow(dead_code)]
impl Token {
pub fn new(
kind: TokenKind,
text: String,
index: usize,
row: usize,
col: usize,
length: usize,
indent: usize,
) -> Self {
Token {
kind,
text,
index,
row,
col,
length,
indent,
tag: 0,
}
}
}