diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2022-12-24 10:03:56 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2022-12-24 10:03:56 +0000 |
commit | ce2db2bc333ed938ec93d5ad0838f8cb720c4865 (patch) | |
tree | 3478f894bd29875c2d4fb5247577d196883bab8a /main/regexast.go | |
parent | c19df3ff75e7693e38940f20a5f3b40931be424a (diff) | |
download | subex-ce2db2bc333ed938ec93d5ad0838f8cb720c4865.tar |
Remove the redundant regex implementation
Diffstat (limited to 'main/regexast.go')
-rw-r--r-- | main/regexast.go | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/main/regexast.go b/main/regexast.go deleted file mode 100644 index a5a60c4..0000000 --- a/main/regexast.go +++ /dev/null @@ -1,92 +0,0 @@ -package main - -import ( - "fmt" -) - -type RegexAST interface { - compileWith(next RegexState) RegexState -} - -type RegexASTRune rune -func (ast RegexASTRune) compileWith(next RegexState) RegexState { - return RegexRuneState{ - rune: rune(ast), - next: next, - } -} -func (ast RegexASTRune) String() string { - return string(rune(ast)) -} - -type RegexASTAny struct {} -func (ast RegexASTAny) compileWith(next RegexState) RegexState { - return RegexAnyState{next} -} -func (ast RegexASTAny) String() string { - return "." -} - -type RegexASTConcat struct { - first, second RegexAST -} -func (ast RegexASTConcat) compileWith(next RegexState) RegexState { - return ast.first.compileWith(ast.second.compileWith(next)) -} -func (ast RegexASTConcat) String() string { - return fmt.Sprintf("Concat{%v, %v}", ast.first, ast.second) -} - -type RegexASTOr struct { - first, second RegexAST -} -func (ast RegexASTOr) compileWith(next RegexState) RegexState { - return RegexGroupState{ - ast.first.compileWith(next), - ast.second.compileWith(next), - } -} - -type RegexASTMaximise struct { - content RegexAST -} -func (ast RegexASTMaximise) compileWith(next RegexState) RegexState { - state := &RegexGroupState{ - nil, - next, - } - state.first = ast.content.compileWith(state) - return state -} - -type RegexASTMinimise struct { - content RegexAST -} -func (ast RegexASTMinimise) compileWith(next RegexState) RegexState { - state := &RegexGroupState{ - next, - nil, - } - state.second = ast.content.compileWith(state) - return state -} - -type RegexASTTry struct { - content RegexAST -} -func (ast RegexASTTry) compileWith(next RegexState) RegexState { - return RegexGroupState{ - ast.content.compileWith(next), - next, - } -} - -type RegexASTMaybe struct { - content RegexAST -} -func (ast RegexASTMaybe) compileWith(next RegexState) RegexState { - return RegexGroupState { - next, - ast.content.compileWith(next), - } -} |