diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-02-19 09:27:55 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-02-19 09:27:55 +0000 |
commit | 3bd45dc49a35b82dcc4ae93796c3e152d799bc0b (patch) | |
tree | 3a681ac5dbd777d2b6b116429cfbd934815661ce /main/main.go | |
parent | a5a4db8283fda88c5bd42272de0258e5d134c5bd (diff) | |
download | stred-go-3bd45dc49a35b82dcc4ae93796c3e152d799bc0b.tar |
Move JSON serialising, deserialising and walking code into a separate package
Diffstat (limited to 'main/main.go')
-rw-r--r-- | main/main.go | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/main/main.go b/main/main.go index 46b83e7..d657ea2 100644 --- a/main/main.go +++ b/main/main.go @@ -5,36 +5,15 @@ import ( "bufio" "fmt" "main/subex" + "main/walk" ) -type PathSegment interface {} -type Path []PathSegment - -type TerminalValue int -const ( - ArrayBegin TerminalValue = iota - ArrayEnd - MapBegin - MapEnd -) -type ValueNull struct {} -type ValueBool bool -type ValueNumber float64 -type ValueString string - -type WalkValue interface {} - -type WalkItem struct { - value WalkValue - path Path -} - type Program []Command type ProgramState struct { - space []WalkItem - in chan WalkItem - out chan WalkItem + space []walk.WalkItem + in chan walk.WalkItem + out chan walk.WalkItem program []Command } @@ -78,17 +57,17 @@ func mainISH() { program := Parse(tokens) stdin := bufio.NewReader(os.Stdin) - dataStream := Json(stdin) + dataStream := walk.Json(stdin) state := ProgramState { in: dataStream, - out: make(chan WalkItem), + out: make(chan walk.WalkItem), program: program, } go func () { for walkItem := range dataStream { - state.space = []WalkItem{walkItem} + state.space = []walk.WalkItem{walkItem} for _, cmd := range state.program { cmd.exec(&state) } @@ -101,5 +80,5 @@ func mainISH() { close(state.out) }() - JsonOut(state.out) + walk.JsonOut(state.out) }
\ No newline at end of file |