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
mod lexer;
pub(crate) mod lexer_constants;
pub use lexer::*;
use std::collections::LinkedList;
mod lexical;
pub trait MacroFormat {
fn macro_fmt(&self) -> String;
}
impl MacroFormat for lexer::Slicer {
fn macro_fmt(&self) -> String {
match self {
Slicer::Index(i) => format!("::data_query_lexical::Slicer::Index({})", i),
Slicer::Slice(f, t) => format!("::data_query_lexical::Slicer::Slice({},{})", f, t),
Slicer::Ident(i) => {
format!("::data_query_lexical::Slicer::Ident(\"{}\".into())", i)
}
}
}
}
impl MacroFormat for LinkedList<lexer::LexOperator> {
fn macro_fmt(&self) -> String {
format!(
"::std::collections::LinkedList::from([{}])",
self.iter()
.map(|t| t.macro_fmt())
.collect::<Vec<String>>()
.join(",")
)
}
}
impl MacroFormat for lexer::LexOperator {
fn macro_fmt(&self) -> String {
match self {
LexOperator::Identifier(i) => {
format!(
"::data_query_lexical::LexOperator::Identifier(\"{}\".into())",
i
)
}
LexOperator::Pipe(p) => p.macro_fmt(),
LexOperator::Generic(g) => format!(
"::data_query_lexical::LexOperator::Generic({})",
g.macro_fmt()
),
}
}
}
impl MacroFormat for lexer::GenericObjectIndex {
fn macro_fmt(&self) -> String {
match self {
GenericObjectIndex::Wildcard => {
format!("::data_query_lexical::GenericObjectIndex::Wildcard")
}
GenericObjectIndex::Slice(s) => format!(
"::data_query_lexical::GenericObjectIndex::Slice(::std::collections::LinkedList::from([{}]))",
s.iter()
.map(|s| s.macro_fmt())
.collect::<Vec<String>>()
.join(",")
),
}
}
}