From 6f107b7a0ccfbcd3e2ec05d91c98877d9b2e0fc7 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Sun, 5 Mar 2023 10:00:28 +0000 Subject: Renames TransducerOutput to OutputContent (and related types) and moves into main/subexstate.go --- subex/subexstate.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'subex/subexstate.go') 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 -- cgit v1.2.3