diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-03-05 10:00:28 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-03-05 10:00:28 +0000 |
commit | 6f107b7a0ccfbcd3e2ec05d91c98877d9b2e0fc7 (patch) | |
tree | 3f2831b0dee324473962bb78f2f6b459dff048cb /subex/subexstate.go | |
parent | ba20360431842bed56109a34e36416a3de5bf905 (diff) | |
download | stred-go-6f107b7a0ccfbcd3e2ec05d91c98877d9b2e0fc7.tar |
Renames TransducerOutput to OutputContent (and related types) and moves into main/subexstate.go
Diffstat (limited to 'subex/subexstate.go')
-rw-r--r-- | subex/subexstate.go | 24 |
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 |