<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-18 14:04:48 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-18 14:04:48 +0100
commitfebdc5dcd5b25a090b90c920914775265da98d39 (patch)
treef55e57e6c65dd9fa4bfc9844d2365f52b350aaf0
parent8e9f0b186745afd51579d2a6136a57705efc7574 (diff)
downloadstred-go-febdc5dcd5b25a090b90c920914775265da98d39.tar
Removes try, maybe, maximise and minimise
These are no longer necessary and have been replaced by repeat
-rw-r--r--subex/parse.go10
-rw-r--r--subex/subexast.go54
2 files changed, 1 insertions, 63 deletions
diff --git a/subex/parse.go b/subex/parse.go
index 24ae082..6e1493b 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -206,7 +206,7 @@ func parseSubex(l *RuneReader, minPower int) SubexAST {
case '[':
rangeParts := parseRangeSubex(l)
lhs = SubexASTRange {rangeParts}
- case ')', '*', '-', '|', '!', '?', ';', '{':
+ case ')', '|', ';', '{':
l.rewind()
return nil
case '$':
@@ -247,14 +247,6 @@ func parseSubex(l *RuneReader, minPower int) SubexAST {
content: lhs,
acceptable: parseRepeatRange(l),
}
- case r == '*' && minPower <= 8:
- lhs = SubexASTMaximise{lhs}
- case r == '-' && minPower <= 8:
- lhs = SubexASTMinimise{lhs}
- case r == '!' && minPower <= 8:
- lhs = SubexASTTry{lhs}
- case r == '?' && minPower <= 8:
- lhs = SubexASTMaybe{lhs}
case r == '|' && minPower <= 4:
rhs := parseSubex(l, 5)
if rhs == nil {
diff --git a/subex/subexast.go b/subex/subexast.go
index 650f038..5e63f03 100644
--- a/subex/subexast.go
+++ b/subex/subexast.go
@@ -48,38 +48,6 @@ func (ast SubexASTOr) compileWith(next SubexState) SubexState {
}
}
-// Run the content subex as many times as possible as the input is read in
-type SubexASTMaximise struct {
- content SubexAST
-}
-func (ast SubexASTMaximise) compileWith(next SubexState) SubexState {
- state := &SubexGroupState {
- nil,
- next,
- }
- state.first = ast.content.compileWith(state)
- return state
-}
-func (ast SubexASTMaximise) String() string {
- return fmt.Sprintf("(%v)*", ast.content)
-}
-
-// Run the content subex as few times as possible as the input is read in
-type SubexASTMinimise struct {
- content SubexAST
-}
-func (ast SubexASTMinimise) compileWith(next SubexState) SubexState {
- state := &SubexGroupState {
- next,
- nil,
- }
- state.second = ast.content.compileWith(state)
- return state
-}
-func (ast SubexASTMinimise) String() string {
- return fmt.Sprintf("(%v)-", ast.content)
-}
-
type ConvexRange struct {
start, end int
}
@@ -185,28 +153,6 @@ func (ast SubexASTOutput) compileWith(next SubexState) SubexState {
}
}
-// Try to use a subex but just skip over this if it doesn't match
-type SubexASTTry struct {
- content SubexAST
-}
-func (ast SubexASTTry) compileWith(next SubexState) SubexState {
- return &SubexGroupState {
- ast.content.compileWith(next),
- next,
- }
-}
-
-// Try to skip over this subex but use it should that not match
-type SubexASTMaybe struct {
- content SubexAST
-}
-func (ast SubexASTMaybe) compileWith(next SubexState) SubexState {
- return &SubexGroupState {
- next,
- ast.content.compileWith(next),
- }
-}
-
// Read in a repeated subex separated by a delimiter. Greedy
type SubexASTJoin struct {
content, delimiter SubexAST