From 3bd45dc49a35b82dcc4ae93796c3e152d799bc0b Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Sun, 19 Feb 2023 09:27:55 +0000 Subject: Move JSON serialising, deserialising and walking code into a separate package --- main/main.go | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'main/main.go') 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 -- cgit v1.2.3