Skip to main content

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    Label(String), // 'name (loop label)
15
16    // Keywords
17    Let,
18    Mut,
19    Fn,
20    Match,
21    If,
22    Else,
23    For,
24    While,
25    Loop,
26    Break,
27    Continue,
28    Return,
29    In,
30    As,
31    None,
32    Some,
33    Ok,
34    Err,
35    Async,
36    Spawn,
37    Await,
38    Select,
39    Try,
40    Catch,
41    Use,
42
43    // Delimiters
44    LParen,    // (
45    RParen,    // )
46    LBrace,    // {
47    RBrace,    // }
48    LBracket,  // [
49    RBracket,  // ]
50    HashBrace, // #{
51
52    // Operators
53    Plus,
54    Minus,
55    Star,
56    Slash,
57    Percent,
58    Eq,        // =
59    EqEq,      // ==
60    BangEq,    // !=
61    Lt,        // <
62    Gt,        // >
63    LtEq,      // <=
64    GtEq,      // >=
65    And,       // &&
66    Or,        // ||
67    Bang,      // !
68    PlusEq,    // +=
69    MinusEq,   // -=
70    StarEq,    // *=
71    SlashEq,   // /=
72    Pipe,      // |>
73    Question,  // ?
74    Ampersand, // &
75    Caret,     // ^
76    Shl,       // <<
77    Shr,       // >>
78    DotDot,    // ..
79    DotDotEq,  // ..=
80    Dot,       // .
81    DotDotDot, // ...
82
83    // Punctuation
84    Comma,
85    Colon,
86    Semicolon,
87    Arrow,      // =>
88    PipeSym,    // | (for closures)
89    ColonColon, // ::
90
91    // Special
92    Eof,
93}
94
95#[derive(Debug, Clone)]
96pub struct SpannedToken {
97    pub token: Token,
98    pub line: usize,
99    pub col: usize,
100}