1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use super::Span;
use parse::ast::*;
use storage::SqlType;
#[derive(Debug)]
pub struct TokenSpan {
pub tok: Token,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Lit {
String(String),
Int(i64),
Float(f64),
Bool(u8),
}
impl Lit {
pub fn into_DataSrc(&self) -> DataSrc {
match self {
&Lit::String(ref s) => DataSrc::String(s.clone()),
&Lit::Int(ref i) => DataSrc::Int(i.clone()),
&Lit::Float(ref f) => DataSrc::String(f.to_string()),
&Lit::Bool(ref b) => DataSrc::Bool(b.clone()),
}
}
pub fn sqltype(&self) -> SqlType {
match self {
&Lit::String(_) => SqlType::Char(0),
&Lit::Int(_) => SqlType::Int,
&Lit::Float(_) => SqlType::Char(0),
&Lit::Bool(_) => SqlType::Bool,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
Word(String),
Literal(Lit),
Semi,
Dot,
Comma,
ParenOp,
ParenCl,
ADel,
Equ,
GThan,
SThan,
GEThan,
SEThan,
NEqu,
Add,
Sub,
Div,
Mod,
Star,
Whitespace,
Unknown
}