<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/filter.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/filter.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/filter.go')
-rw-r--r--main/filter.go93
1 files changed, 0 insertions, 93 deletions
diff --git a/main/filter.go b/main/filter.go
deleted file mode 100644
index d80ae8f..0000000
--- a/main/filter.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package main
-
-import (
- "main/walk"
-)
-
-type PathFilter struct {
- initial PathFilterState
-}
-func (filter PathFilter) exec(space walk.WalkItem) bool {
- pathFilterState := make(map[PathFilterState]struct{})
- pathFilterState[filter.initial] = struct{}{}
- for _, segment := range space.Path {
- nextPathFilterState := make(map[PathFilterState]struct{})
- for curState := range pathFilterState {
- for nextState := range curState.eat(segment) {
- nextPathFilterState[nextState] = struct{}{}
- }
- }
- pathFilterState = nextPathFilterState
- }
- for pathState := range pathFilterState {
- if pathState.accept() {
- return true
- }
- }
- return false
-}
-
-type MapTerminalFilter struct {}
-func (filter MapTerminalFilter) exec(space walk.WalkItem) bool {
- terminal, isTerminal := space.Value.(walk.TerminalValue)
- if !isTerminal {
- return false
- }
- return terminal == walk.MapBegin || terminal == walk.MapEnd
-}
-
-type BeginTerminalFilter struct {}
-func (filter BeginTerminalFilter) exec(space walk.WalkItem) bool {
- terminal, isTerminal := space.Value.(walk.TerminalValue)
- if !isTerminal {
- return false
- }
- return terminal == walk.ArrayBegin || terminal == walk.MapBegin
-}
-
-type EndTerminalFilter struct {}
-func (filter EndTerminalFilter) exec(space walk.WalkItem) bool {
- terminal, isTerminal := space.Value.(walk.TerminalValue)
- if !isTerminal {
- return false
- }
- return terminal == walk.ArrayEnd || terminal == walk.MapEnd
-}
-
-type TerminalFilter struct {}
-func (filter TerminalFilter) exec(space walk.WalkItem) bool {
- _, isTerminal := space.Value.(walk.TerminalValue)
- return isTerminal
-}
-
-type RootFilter struct {}
-func (filter RootFilter) exec(space walk.WalkItem) bool {
- return len(space.Path) == 0
-}
-
-type AndFilter struct {
- left Filter
- right Filter
-}
-func (filter AndFilter) exec(space walk.WalkItem) bool {
- return filter.left.exec(space) && filter.right.exec(space)
-}
-
-type OrFilter struct {
- left Filter
- right Filter
-}
-func (filter OrFilter) exec(space walk.WalkItem) bool {
- return filter.left.exec(space) || filter.right.exec(space)
-}
-
-type NotFilter struct {
- content Filter
-}
-func (filter NotFilter) exec(space walk.WalkItem) bool {
- return !filter.content.exec(space)
-}
-
-type Filter interface {
- exec(walk.WalkItem) bool
-} \ No newline at end of file