1use crate::utils::location::Location;
2
3#[derive(Debug, Clone, PartialEq)]
4pub enum TokenType {
5 Equals,
7 NotEquals,
8 LessThan,
9 GreaterThan,
10 LessThanEquals,
11 GreaterThanEquals,
12 Or,
13 And,
14
15 Assign,
17 LParen,
18 RParen,
19 LBrace,
20 RBrace,
21 SemiColon,
22 Colon,
23 DoubleColon,
24 Period,
25 Comma,
26 LBracket,
27 RBracket,
28
29 Ampersand,
31 Star,
32
33 Add, Minus, Divide, Multiply, Modulo, Not, True,
43 False,
44
45 VarKeyword,
47 IfKeyword,
48 ElseKeyword,
49 WhileKeyword,
50 FnKeyword,
51 PubKeyword,
52 ReturnKeyword,
53 ExternKeyword,
54 ForKeyword,
55 UseKeyword,
56 StructKeyword,
57 SizeOfKeyword,
58 BreakKeyword,
59 ConstKeyword,
60 AsKeyword,
61 ElseIfKeyword,
62
63 Identifier,
65
66 IntLiteral,
68 CharLiteral,
69 StringLiteral,
70
71 Niltoken,
73}
74
75#[derive(Clone, Debug)]
76pub struct Token {
77 pub ttype: TokenType,
78 pub location: Location,
79 pub value: String,
80}
81impl std::fmt::Display for Token {
82 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83 write!(
84 f,
85 "Token {{ Type: {:?}, Location: ({}, {}), Value: {} }}",
86 self.ttype, self.location.line, self.location.col, self.value
87 )
88 }
89}