diff options
Diffstat (limited to 'main/pathfilterast.go')
-rw-r--r-- | main/pathfilterast.go | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/main/pathfilterast.go b/main/pathfilterast.go deleted file mode 100644 index c84b8af..0000000 --- a/main/pathfilterast.go +++ /dev/null @@ -1,74 +0,0 @@ -package main - -type StringSegmentPathFilterAST struct { - index string -} -func (ast StringSegmentPathFilterAST) compileWith(next PathFilterState) PathFilterState { - return StringSegmentPathFilter { - index: ast.index, - next: next, - } -} - -type IntegerSegmentPathFilterAST struct { - index int -} -func (ast IntegerSegmentPathFilterAST) compileWith(next PathFilterState) PathFilterState { - return IntegerSegmentPathFilter { - index: ast.index, - next: next, - } -} - -type RepeatPathFilterAST struct { - content PathFilterAST -} -func (ast RepeatPathFilterAST) compileWith(next PathFilterState) PathFilterState { - nextGroup := &OrPathFilter{} - repeatStart := ast.content.compileWith(nextGroup) - nextGroup.filters = [2]PathFilterState{next, repeatStart} - return nextGroup -} - -type SequencePathFilterAST struct { - first PathFilterAST - second PathFilterAST -} -func (ast SequencePathFilterAST) compileWith(next PathFilterState) PathFilterState { - next = ast.second.compileWith(next) - next = ast.first.compileWith(next) - return next -} - -type AnySegmentPathFilterAST struct {} -func (ast AnySegmentPathFilterAST) compileWith(next PathFilterState) PathFilterState { - return AnySegmentPathFilter{next: next} -} - -type OrPathFilterAST struct { - first PathFilterAST - second PathFilterAST -} -func (ast OrPathFilterAST) compileWith(next PathFilterState) PathFilterState { - return OrPathFilter { - filters: [2]PathFilterState{ - ast.first.compileWith(next), - ast.second.compileWith(next), - }, - } -} - -type NonePathFilterAST struct {} -func (ast NonePathFilterAST) compileWith(next PathFilterState) PathFilterState { - return next -} - -type PathFilterAST interface { - compileWith(PathFilterState) PathFilterState -} - -func compilePathFilterAST(ast PathFilterAST) PathFilter { - return PathFilter{ - initial: ast.compileWith(NonePathFilter{}), - } -} |