diff options
Diffstat (limited to 'main/pathfilter.go')
-rw-r--r-- | main/pathfilter.go | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/main/pathfilter.go b/main/pathfilter.go index 7b6c64f..b64872e 100644 --- a/main/pathfilter.go +++ b/main/pathfilter.go @@ -1,20 +1,5 @@ package main -type MapTerminalFilter struct {} -func (filter MapTerminalFilter) exec(state *ProgramState) bool { - terminal, isTerminal := state.space.value.(TerminalValue) - if !isTerminal { - return false - } - return terminal == MapBegin || terminal == MapEnd -} - -type NonTerminalFilter struct {} -func (filter NonTerminalFilter) exec(state *ProgramState) bool { - _, isTerminal := state.space.value.(TerminalValue) - return !isTerminal -} - type AnySegmentPathFilter struct { next PathFilterState } @@ -72,6 +57,22 @@ func (filter StringSegmentPathFilter) accept() bool { return false } +type IntegerSegmentPathFilter struct { + index int + next PathFilterState +} +func (filter IntegerSegmentPathFilter) eat(segment 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(PathSegment) map[PathFilterState]struct{} accept() bool |