1use std::fmt;
2
3use yolol_number::YololNumber;
4
5#[derive(Debug, PartialEq, Eq, Clone)]
6pub enum Token
7{
8 Comment(String),
9 Identifier(String),
10 StringToken(String),
11 YololNum(YololNumber),
12
13 Goto,
14
15 If,
16 Then,
17 Else,
18 End,
19
20 Abs,
21 Sqrt,
22 Sin,
23 Cos,
24 Tan,
25 Arcsin,
26 Arccos,
27 Arctan,
28 Not,
29
30 Or,
31 And,
32
33 Newline,
34
35 Equal,
36 Plus,
37 Minus,
38 Star,
39 Slash,
40 LParen,
41 RParen,
42 LAngleBrak,
43 RAngleBrak,
44 Exclam,
45 Caret,
46 Percent,
47}
48
49impl fmt::Display for Token
50{
51 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
52 {
53 let write_value: String = match self
54 {
55 Token::Comment(string) => format!("// {}\n", string),
56 Token::Identifier(string) => string.clone(),
57 Token::StringToken(string) => format!("\"{}\"", string),
58 Token::YololNum(num) => format!("{}", num),
59
60 Token::Goto => "goto".to_owned(),
61
62 Token::If => "if".to_owned(),
63 Token::Then => "then".to_owned(),
64 Token::Else => "else".to_owned(),
65 Token::End => "end".to_owned(),
66
67 Token::Abs => "abs".to_owned(),
68 Token::Sqrt => "sqrt".to_owned(),
69 Token::Sin => "sin".to_owned(),
70 Token::Cos => "cos".to_owned(),
71 Token::Tan => "tan".to_owned(),
72 Token::Arcsin => "arcsin".to_owned(),
73 Token::Arccos => "arccos".to_owned(),
74 Token::Arctan => "arctan".to_owned(),
75 Token::Not => "not".to_owned(),
76
77 Token::Or => "or".to_owned(),
78 Token::And => "and".to_owned(),
79
80 Token::Newline => "\n".to_owned(),
81
82 Token::Equal => "=".to_owned(),
83 Token::Plus => "+".to_owned(),
84 Token::Minus => "-".to_owned(),
85 Token::Star => "*".to_owned(),
86 Token::Slash => "/".to_owned(),
87 Token::LParen => "(".to_owned(),
88 Token::RParen => ")".to_owned(),
89 Token::LAngleBrak => "<".to_owned(),
90 Token::RAngleBrak => ">".to_owned(),
91 Token::Exclam => "!".to_owned(),
92 Token::Caret => "^".to_owned(),
93 Token::Percent => "%".to_owned(),
94 };
95
96 write!(f, "{}", write_value)
97 }
98}
99
100
101
102
103
104
105
106