From 184118c1522ee4e78a0588fcac8eb235f512b599 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Fri, 21 Apr 2023 11:19:18 +0100 Subject: Add :xyz: replacement syntax that removes whatever is before it and inserts whatever is inside it --- subex/subexast.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'subex/subexast.go') 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) +} -- cgit v1.2.3