<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/main.go')
-rw-r--r--subex/main.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/subex/main.go b/subex/main.go
index 9824f10..bb688e9 100644
--- a/subex/main.go
+++ b/subex/main.go
@@ -103,13 +103,13 @@ func pruneStates(states []SubexBranch) (newStates []SubexBranch) {
}
// Run the subex transducer
-func RunTransducer(transducer SubexState, input <-chan walk.Atom) (output []walk.Atom, err bool) {
+func RunTransducer(transducer SubexState, input []walk.Atom) (output []walk.Atom, err bool) {
states := []SubexBranch{{
state: transducer,
outputStack: OutputStackNil{}.push(nil),
store: make(Store),
}}
- for piece := range input {
+ for _, piece := range input {
var newStates []SubexBranch
for _, state := range states {
newStates = append(newStates, state.eat(piece)...)
@@ -149,7 +149,12 @@ func Main() {
close(out)
}(jsonStream, tokenStream)
- atoms := walk.Atomise(tokenStream)
+ var tokens []walk.WalkValue
+ for token := range tokenStream {
+ tokens = append(tokens, token)
+ }
+
+ atoms := walk.Atomise(tokens)
output, err := RunTransducer(transducer, atoms)
if err {
@@ -157,7 +162,7 @@ func Main() {
return
}
- valueOut, error := walk.MemoryCompound(output)
+ valueOut, error := walk.Compound(output)
if error != nil {
fmt.Println(error.Error())
return