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/parse.go | |
parent | c19df3ff75e7693e38940f20a5f3b40931be424a (diff) | |
download | subex-ce2db2bc333ed938ec93d5ad0838f8cb720c4865.tar |
Remove the redundant regex implementation
Diffstat (limited to 'main/parse.go')
-rw-r--r-- | main/parse.go | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/main/parse.go b/main/parse.go index 18941f2..59104c1 100644 --- a/main/parse.go +++ b/main/parse.go @@ -21,57 +21,6 @@ func parseReplacement(l *RuneReader) (output []TransducerOutput) { return output } -func parseRegex(l *RuneReader, minPower int) RegexAST { - var lhs RegexAST - r := l.next() - switch r { - case eof: - return nil - case ')', '*', '-', '|', '?', '!': - l.rewind() - return nil - case '(': - lhs = parseRegex(l, 0) - if !l.accept(")") { - panic("Missing matching )") - } - case '.': - lhs = RegexASTAny{} - default: - lhs = RegexASTRune(r) - } - loop: for { - if minPower <= 0 { - next := parseRegex(l, 1) - if next != nil { - lhs = RegexASTConcat{lhs, next} - continue loop - } - } - r := l.next() - switch { - case r == '*' && minPower <= 4: - lhs = RegexASTMaximise{lhs} - case r == '-' && minPower <= 4: - lhs = RegexASTMinimise{lhs} - case r == '!' && minPower <= 4: - lhs = RegexASTTry{lhs} - case r == '?' && minPower <= 4: - lhs = RegexASTMaybe{lhs} - case r == '|' && minPower <= 2: - rhs := parseRegex(l, 3) - if rhs == nil { - panic("Missing regex after |") - } - lhs = RegexASTOr{lhs, rhs} - default: - l.rewind() - break loop - } - } - return lhs -} - func parseSubex(l *RuneReader, minPower int) SubexAST { var lhs SubexAST r := l.next() |