blob: 1a1b6db9541aeb4f1b014b2ae812bd59b124ffb0 (
plain)
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
|
package subex
import (
"main/walk"
)
type valueFilter interface {
valueFilter(value walk.Value) bool
}
type selectScalarFilter struct {
scalar walk.Scalar
}
func (scalar selectScalarFilter) valueFilter(value walk.Value) bool {
return value == scalar.scalar
}
type anyNumberFilter struct {}
func (_ anyNumberFilter) valueFilter(value walk.Value) bool {
_, isNumber := value.(walk.NumberScalar)
return isNumber
}
type anyBoolFilter struct {}
func (_ anyBoolFilter) valueFilter(value walk.Value) bool {
_, isBool := value.(walk.BoolScalar)
return isBool
}
type anyValueFilter struct {}
func (_ anyValueFilter) valueFilter(value walk.Value) bool {
return true
}
type anyArrayFilter struct {}
func (_ anyArrayFilter) valueFilter(value walk.Value) bool {
_, isArray := value.(walk.ArrayStructure)
return isArray
}
type anyStringFilter struct {}
func (_ anyStringFilter) valueFilter(value walk.Value) bool {
_, isString := value.(walk.StringStructure)
return isString
}
type runeFilter interface {
runeFilter(r walk.StringRuneAtom) bool
}
type anyRuneFilter struct {}
func (_ anyRuneFilter) runeFilter(r walk.StringRuneAtom) bool {
return true
}
type selectRuneFilter struct {
r rune
}
func (f selectRuneFilter) runeFilter(r walk.StringRuneAtom) bool {
return f.r == rune(r)
}
|