diff options
Diffstat (limited to 'main/pathfilter.go')
-rw-r--r-- | main/pathfilter.go | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/main/pathfilter.go b/main/pathfilter.go deleted file mode 100644 index 1af3b6d..0000000 --- a/main/pathfilter.go +++ /dev/null @@ -1,83 +0,0 @@ -package main - -import ( - "main/walk" -) - -type AnySegmentPathFilter struct { - next PathFilterState -} -func (filter AnySegmentPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { - res := make(map[PathFilterState]struct{}) - res[filter.next] = struct{}{} - return res -} -func (filter AnySegmentPathFilter) accept() bool { - return false -} - -type OrPathFilter struct { - filters [2]PathFilterState -} -func (filter OrPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { - res := make(map[PathFilterState]struct{}) - for _, f := range filter.filters { - for r := range f.eat(segment) { - res[r] = struct{}{} - } - } - return res -} -func (filter OrPathFilter) accept() bool { - for _, f := range filter.filters { - if f.accept() { - return true - } - } - return false -} - -type NonePathFilter struct {} -func (filter NonePathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { - return make(map[PathFilterState]struct{}) -} -func (filter NonePathFilter) accept() bool { - return true -} - -type StringSegmentPathFilter struct { - index string - next PathFilterState -} -func (filter StringSegmentPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { - s, isString := segment.(string) - res := make(map[PathFilterState]struct{}) - if isString && s == filter.index { - res[filter.next] = struct{}{} - } - return res -} -func (filter StringSegmentPathFilter) accept() bool { - return false -} - -type IntegerSegmentPathFilter struct { - index int - next PathFilterState -} -func (filter IntegerSegmentPathFilter) eat(segment walk.PathSegment) map[PathFilterState]struct{} { - i, isInteger := segment.(int) - res := make(map[PathFilterState]struct{}) - if isInteger && i == filter.index { - res[filter.next] = struct{}{} - } - return res -} -func (filter IntegerSegmentPathFilter) accept() bool { - return false -} - -type PathFilterState interface { - eat(walk.PathSegment) map[PathFilterState]struct{} - accept() bool -} |