ion_core/token.rs
1#[derive(Debug, Clone, PartialEq)]
2pub enum Token {
3 // Literals
4 Int(i64),
5 Float(f64),
6 Str(String),
7 FStr(String), // f"..." interpolated string (raw template)
8 Bytes(Vec<u8>), // b"..." byte literal
9 True,
10 False,
11
12 // Identifiers
13 Ident(String),
14
15 // Keywords
16 Let,
17 Mut,
18 Fn,
19 Match,
20 If,
21 Else,
22 For,
23 While,
24 Loop,
25 Break,
26 Continue,
27 Return,
28 In,
29 As,
30 None,
31 Some,
32 Ok,
33 Err,
34 Async,
35 Spawn,
36 Await,
37 Select,
38 Try,
39 Catch,
40 Use,
41
42 // Delimiters
43 LParen, // (
44 RParen, // )
45 LBrace, // {
46 RBrace, // }
47 LBracket, // [
48 RBracket, // ]
49 HashBrace, // #{
50
51 // Operators
52 Plus,
53 Minus,
54 Star,
55 Slash,
56 Percent,
57 Eq, // =
58 EqEq, // ==
59 BangEq, // !=
60 Lt, // <
61 Gt, // >
62 LtEq, // <=
63 GtEq, // >=
64 And, // &&
65 Or, // ||
66 Bang, // !
67 PlusEq, // +=
68 MinusEq, // -=
69 StarEq, // *=
70 SlashEq, // /=
71 Pipe, // |>
72 Question, // ?
73 Ampersand, // &
74 Caret, // ^
75 Shl, // <<
76 Shr, // >>
77 DotDot, // ..
78 DotDotEq, // ..=
79 Dot, // .
80 DotDotDot, // ...
81
82 // Punctuation
83 Comma,
84 Colon,
85 Semicolon,
86 Arrow, // =>
87 PipeSym, // | (for closures)
88 ColonColon, // ::
89
90 // Special
91 Eof,
92}
93
94#[derive(Debug, Clone)]
95pub struct SpannedToken {
96 pub token: Token,
97 pub line: usize,
98 pub col: usize,
99}