<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/pathfilter.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-20 09:59:59 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-20 09:59:59 +0100
commita0a416e7762fcdcc066617da8083b0372b87155c (patch)
tree84217b9d1a9496944ddfeee8687cd01f6997cc3e /main/pathfilter.go
parentb95e5ddaa1b182dfe58a386bfc107fa7d95c4393 (diff)
downloadstred-go-a0a416e7762fcdcc066617da8083b0372b87155c.tar
Remove filters and various commands that are no longer wanted
These have all been made redundant by the incredible substitute command
Diffstat (limited to 'main/pathfilter.go')
-rw-r--r--main/pathfilter.go83
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
-}