Skip to main content

powdb_query/
token.rs

1#[derive(Debug, Clone, PartialEq)]
2pub enum Token {
3    // Identifiers and literals
4    Ident(String),     // User, name, email
5    DotIdent(String),  // .name, .age (field access)
6    IntLit(i64),       // 42
7    FloatLit(f64),     // 3.14
8    StringLit(String), // "hello"
9    BoolLit(bool),     // true, false
10    Param(String),     // $age, $name (query parameter)
11
12    // Keywords
13    Type,         // type
14    Filter,       // filter
15    Order,        // order
16    Limit,        // limit
17    Offset,       // offset
18    Insert,       // insert
19    Update,       // update
20    Delete,       // delete
21    Upsert,       // upsert
22    Select,       // select (alias for projection)
23    Required,     // required
24    Multi,        // multi
25    Link,         // link
26    Index,        // index
27    On,           // on
28    Conflict,     // conflict
29    Asc,          // asc
30    Desc,         // desc
31    And,          // and
32    Or,           // or
33    Not,          // not
34    Exists,       // exists
35    Let,          // let
36    As,           // as
37    Match,        // match
38    Group,        // group
39    Join,         // join
40    Inner,        // inner
41    LeftKw,       // left  (keyword — avoids clashing with ast::JoinKind::LeftOuter naming)
42    RightKw,      // right
43    Outer,        // outer
44    Cross,        // cross
45    Transaction,  // transaction
46    View,         // view
47    Materialized, // materialized
48    Refresh,      // refresh
49    Union,        // union
50    Having,       // having
51    Distinct,     // distinct
52    In,           // in
53    Between,      // between
54    Like,         // like
55    Count,        // count
56    Avg,          // avg
57    Sum,          // sum
58    Min,          // min
59    Max,          // max
60    Is,           // is
61    Null,         // null
62
63    // String functions
64    Upper,     // upper
65    Lower,     // lower
66    Length,    // length
67    Trim,      // trim
68    Substring, // substring
69    Concat,    // concat
70
71    // Math functions
72    Abs,   // abs
73    Round, // round
74    Ceil,  // ceil
75    Floor, // floor
76    Sqrt,  // sqrt
77    Pow,   // pow
78
79    // Date/time functions
80    Now,      // now
81    Extract,  // extract
82    DateAdd,  // date_add
83    DateDiff, // date_diff
84
85    // Type conversion
86    Cast, // cast
87
88    // CASE WHEN
89    Case, // case
90    When, // when
91    Then, // then
92    Else, // else
93    End,  // end
94
95    // Window functions
96    Over,      // over
97    Partition, // partition
98    RowNumber, // row_number
99    Rank,      // rank
100    DenseRank, // dense_rank
101
102    // DDL
103    Alter,   // alter
104    Drop,    // drop
105    Add,     // add
106    Column,  // column
107    Explain, // explain
108
109    // Operators
110    Eq,       // =
111    Neq,      // !=
112    Lt,       // <
113    Gt,       // >
114    Lte,      // <=
115    Gte,      // >=
116    Assign,   // :=
117    Arrow,    // ->
118    Pipe,     // |
119    Coalesce, // ??
120    Plus,     // +
121    Minus,    // -
122    Star,     // *
123    Slash,    // /
124
125    // Delimiters
126    LBrace, // {
127    RBrace, // }
128    LParen, // (
129    RParen, // )
130    Comma,  // ,
131    Colon,  // :
132    Dot,    // .
133
134    // Special
135    Eof,
136}