diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-03-05 09:11:09 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-03-05 09:11:09 +0000 |
commit | ba20360431842bed56109a34e36416a3de5bf905 (patch) | |
tree | 70ba08b8227a1cb5a92437e30f1f3d00d1892a15 | |
parent | 62b61b1ea2bc8c5e5d447ddc4529b7977439804a (diff) | |
download | stred-go-ba20360431842bed56109a34e36416a3de5bf905.tar |
Changes the slot map so only runes can be used as slots
-rw-r--r-- | subex/main.go | 10 | ||||
-rw-r--r-- | subex/parse.go | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/subex/main.go b/subex/main.go index fd59047..fd0d356 100644 --- a/subex/main.go +++ b/subex/main.go @@ -23,18 +23,16 @@ func (replacement TransducerReplacementAtom) build(store Store) []walk.Atom { return []walk.Atom{replacement.atom} } -// TODO should be a single field called slot with a type of rune // A TransducerOutput which is a slot that is loaded from type TransducerReplacementLoad struct { - atom walk.Atom + slot rune } func (replacement TransducerReplacementLoad) build(store Store) []walk.Atom { - return store[replacement.atom] + return store[replacement.slot] } // Where slots are stored -// TODO should map from runes as only runes can be slots -type Store map[walk.Atom][]walk.Atom +type Store map[rune][]walk.Atom // Return a new store with all the data from this one func (store Store) clone() Store { newStore := make(Store) @@ -44,7 +42,7 @@ func (store Store) clone() Store { return newStore } // Return a copy of this store but with an additional slot set -func (store Store) withValue(key walk.Atom, value []walk.Atom) Store { +func (store Store) withValue(key rune, value []walk.Atom) Store { newStore := store.clone() newStore[key] = value return newStore diff --git a/subex/parse.go b/subex/parse.go index 1d64c20..16bc620 100644 --- a/subex/parse.go +++ b/subex/parse.go @@ -43,7 +43,7 @@ func parseReplacement(l *RuneReader) (output []TransducerOutput) { if slot == eof { panic("Missing slot character") } - output = append(output, TransducerReplacementLoad{atom: slot}) + output = append(output, TransducerReplacementLoad{slot: slot}) case '@', '~', '#': output = append(output, TransducerReplacementAtom{atom: parseTerminatorAtomLiteral(r, l)}) default: |