<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/subexstate.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/subexstate.go')
-rw-r--r--subex/subexstate.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/subex/subexstate.go b/subex/subexstate.go
index 12ace42..5a38d0b 100644
--- a/subex/subexstate.go
+++ b/subex/subexstate.go
@@ -62,9 +62,31 @@ func (state SubexStoreState) accepting(store Store) (outputs [][]walk.Atom) {
return outputs
}
+// A part of an output literal, either an Atom or a slot from which to load
+type OutputContent interface {
+ // Given the current store, return the []Atom produced by the TransducerOutput
+ build(Store) []walk.Atom
+}
+
+// An OutputContent which is just an Atom literal
+type OutputAtomLiteral struct {
+ atom walk.Atom
+}
+func (replacement OutputAtomLiteral) build(store Store) []walk.Atom {
+ return []walk.Atom{replacement.atom}
+}
+
+// An OutputContent which is a slot that is loaded from
+type OutputLoad struct {
+ slot rune
+}
+func (replacement OutputLoad) build(store Store) []walk.Atom {
+ return store[replacement.slot]
+}
+
// Don't read in anything, just output the series of data and slots specified
type SubexOutputState struct {
- content []TransducerOutput
+ content []OutputContent
next SubexState
}
// Given a store, return what is outputted by an epsilon transition from this state