<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/subexast.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-21 11:19:18 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-21 11:19:18 +0100
commit184118c1522ee4e78a0588fcac8eb235f512b599 (patch)
treecf32b7fff7e820e0b81e6975fee661f554c5c717 /subex/subexast.go
parent80e7fd0626bfb98f8c1b7f69726d88f8cfa3e4fc (diff)
downloadstred-go-184118c1522ee4e78a0588fcac8eb235f512b599.tar
Add :xyz: replacement syntax that removes whatever is before it and inserts whatever is inside it
Diffstat (limited to 'subex/subexast.go')
-rw-r--r--subex/subexast.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/subex/subexast.go b/subex/subexast.go
index ee7a959..dd98aa9 100644
--- a/subex/subexast.go
+++ b/subex/subexast.go
@@ -359,3 +359,16 @@ func (ast SubexASTEmpty) compileWith(next SubexState) SubexState {
func (ast SubexASTEmpty) String() string {
return "()"
}
+
+// Discards the output from the content subex
+type SubexASTDiscard struct {
+ Content SubexAST
+}
+func (ast SubexASTDiscard) compileWith(next SubexState) SubexState {
+ return &SubexCaptureBeginState {
+ next: ast.Content.compileWith(&SubexDiscardState {next}),
+ }
+}
+func (ast SubexASTDiscard) String() string {
+ return fmt.Sprintf("(%v)$_", ast.Content)
+}