<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/subexstate.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/subexstate.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/subexstate.go')
-rw-r--r--subex/subexstate.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/subex/subexstate.go b/subex/subexstate.go
index 997e6ce..b5e1e9b 100644
--- a/subex/subexstate.go
+++ b/subex/subexstate.go
@@ -36,6 +36,19 @@ func (state SubexCaptureBeginState) accepting(store Store, outputStack OutputSta
return state.next.accepting(store, outputStack.push(nil))
}
+// Discard the top of the OutputStack
+type SubexDiscardState struct {
+ next SubexState
+}
+func (state SubexDiscardState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch {
+ _, newStack := outputStack.pop()
+ return state.next.eat(store, newStack, char)
+}
+func (state SubexDiscardState) accepting(store Store, outputStack OutputStack) []OutputStack {
+ _, newStack := outputStack.pop()
+ return state.next.accepting(store, newStack)
+}
+
// Pop the top of the OutputStack which contains the stuff outputted since the start of the store
// This outputted data gets stored in a slot
type SubexStoreEndState struct {