-
Notifications
You must be signed in to change notification settings - Fork 3
/
walker.go
68 lines (56 loc) · 973 Bytes
/
walker.go
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
package kvql
func (e *BinaryOpExpr) Walk(cb WalkCallback) {
if cb(e) {
e.Left.Walk(cb)
e.Right.Walk(cb)
}
}
func (e *FieldExpr) Walk(cb WalkCallback) {
cb(e)
}
func (e *FieldReferenceExpr) Walk(cb WalkCallback) {
if cb(e) {
e.FieldExpr.Walk(cb)
}
}
func (e *StringExpr) Walk(cb WalkCallback) {
cb(e)
}
func (e *NotExpr) Walk(cb WalkCallback) {
if cb(e) {
e.Right.Walk(cb)
}
}
func (e *FunctionCallExpr) Walk(cb WalkCallback) {
if cb(e) {
e.Name.Walk(cb)
for _, arg := range e.Args {
arg.Walk(cb)
}
}
}
func (e *NameExpr) Walk(cb WalkCallback) {
cb(e)
}
func (e *NumberExpr) Walk(cb WalkCallback) {
cb(e)
}
func (e *FloatExpr) Walk(cb WalkCallback) {
cb(e)
}
func (e *BoolExpr) Walk(cb WalkCallback) {
cb(e)
}
func (e *ListExpr) Walk(cb WalkCallback) {
if cb(e) {
for _, item := range e.List {
item.Walk(cb)
}
}
}
func (e *FieldAccessExpr) Walk(cb WalkCallback) {
if cb(e) {
e.Left.Walk(cb)
e.FieldName.Walk(cb)
}
}