diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/command.go | 9 | ||||
-rw-r--r-- | main/main.go | 18 |
2 files changed, 15 insertions, 12 deletions
diff --git a/main/command.go b/main/command.go index 63cc3b8..ef48596 100644 --- a/main/command.go +++ b/main/command.go @@ -13,12 +13,13 @@ type Command interface { type PrintValueCommand struct {} func (cmd PrintValueCommand) exec(state *ProgramState) { - pathValues, err := walk.Compound(state.path) + err := state.out.Write(walk.WalkItem { + Path: state.path, + Value: state.value, + }) if err != nil { - panic("Tried to convert invalid atoms to values") + panic("Error while outputting") } - path := walk.PathFromWalkValues(pathValues) - state.out.Print(path, state.value) state.pc++ } func (cmd PrintValueCommand) String() string { diff --git a/main/main.go b/main/main.go index 55ed5b5..668253d 100644 --- a/main/main.go +++ b/main/main.go @@ -4,14 +4,15 @@ import ( "os" "bufio" "main/walk" + "main/json_tokens" ) type Program []Command type ProgramState struct { path, value, xreg, yreg, zreg []walk.Atom - in walk.JSONIn - out walk.JSONOut + in walk.StredReader + out walk.StredWriter program []Command pc int } @@ -44,8 +45,8 @@ func main() { stdout := bufio.NewWriter(os.Stdout) state := ProgramState { - in: walk.NewJSONIn(stdin), - out: walk.NewJSONOut(stdout), + in: json_tokens.NewJSONIn(stdin), + out: json_tokens.NewJSONOut(stdout), program: program, } @@ -61,12 +62,13 @@ func main() { state.program[state.pc].exec(&state) } if !quiet { - pathValues, err := walk.Compound(state.path) + err := state.out.Write(walk.WalkItem { + Path: state.path, + Value: state.value, + }) if err != nil { - panic("Tried to convert invalid atoms to values") + panic("Error while outputting") } - path := walk.PathFromWalkValues(pathValues) - state.out.Print(path, state.value) } } |