<- 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.go49
1 files changed, 0 insertions, 49 deletions
diff --git a/subex/main.go b/subex/main.go
index bb688e9..ae829d9 100644
--- a/subex/main.go
+++ b/subex/main.go
@@ -1,9 +1,6 @@
package subex
import (
- "os"
- "fmt"
- "bufio"
"main/walk"
)
@@ -125,49 +122,3 @@ func RunTransducer(transducer SubexState, input []walk.Atom) (output []walk.Atom
}
return nil, true
}
-
-func Main() {
- if len(os.Args) != 2 {
- panic("Expected: program [subex]")
- }
- program := os.Args[1]
- reader := &StringRuneReader {
- input: program,
- pos: 0,
- width: 0,
- }
- ast := Parse(reader)
- transducer := CompileTransducer(ast)
-
- stdin := bufio.NewReader(os.Stdin);
- jsonStream := walk.Json(stdin);
- tokenStream := make(chan walk.WalkValue)
- go func(in <-chan walk.WalkItem, out chan<- walk.WalkValue) {
- for item := range in {
- out<-item.Value
- }
- close(out)
- }(jsonStream, tokenStream)
-
- var tokens []walk.WalkValue
- for token := range tokenStream {
- tokens = append(tokens, token)
- }
-
- atoms := walk.Atomise(tokens)
-
- output, err := RunTransducer(transducer, atoms)
- if err {
- fmt.Println("Error")
- return
- }
-
- valueOut, error := walk.Compound(output)
- if error != nil {
- fmt.Println(error.Error())
- return
- }
- for _, value := range valueOut {
- fmt.Println(value)
- }
-}