diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-21 16:22:16 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-21 16:22:16 +0100 |
commit | 12c1d179f32c38a929fcc9adb326a9f44c8288ae (patch) | |
tree | d685922ed93708cbaf01357a95989283a7b86443 /subex/subexstate.go | |
parent | 5d8582711936cae3c42f2645d0f304418b17fb7e (diff) | |
download | stred-go-12c1d179f32c38a929fcc9adb326a9f44c8288ae.tar |
Replaces the interfaces implementation of Atom with a tagged union based implementation
Diffstat (limited to 'subex/subexstate.go')
-rw-r--r-- | subex/subexstate.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/subex/subexstate.go b/subex/subexstate.go index b5e1e9b..56063c0 100644 --- a/subex/subexstate.go +++ b/subex/subexstate.go @@ -153,8 +153,7 @@ type SubexCopyBoolState struct { next SubexState } func (state SubexCopyBoolState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch { - _, isBool := char.(walk.ValueBool) - if isBool { + if char.Typ == walk.AtomBool { return []SubexBranch{{ state: state.next, outputStack: topAppend(outputStack, []walk.Atom{char}), @@ -172,8 +171,7 @@ type SubexCopyNumberState struct { next SubexState } func (state SubexCopyNumberState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch { - _, isNumber := char.(walk.ValueNumber) - if isNumber { + if char.Typ == walk.AtomNumber { return []SubexBranch{{ state: state.next, outputStack: topAppend(outputStack, []walk.Atom{char}), @@ -191,8 +189,7 @@ type SubexCopyStringAtomState struct { next SubexState } func (state SubexCopyStringAtomState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch { - _, isStringAtom := char.(walk.StringAtom) - if isStringAtom { + if char.Typ == walk.AtomStringRune { return []SubexBranch{{ state: state.next, outputStack: topAppend(outputStack, []walk.Atom{char}), @@ -210,9 +207,7 @@ type SubexCopyNonStringAtomState struct { next SubexState } func (state SubexCopyNonStringAtomState) eat(store Store, outputStack OutputStack, char walk.Atom) []SubexBranch { - _, isStringAtom := char.(walk.StringAtom) - _, isStringTerminal := char.(walk.StringTerminal) - if isStringAtom || isStringTerminal { + if char.Typ == walk.AtomStringRune || char.Typ == walk.AtomStringTerminal { return nil } return []SubexBranch{{ |