From 8cf10efe3b5a1bcc70bc6e5590ee63fd5eb00c5b Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 19 Jul 2023 11:57:59 +0100 Subject: Huge refactor to a more value based system, doing away with terminals. Also introduces unit testing --- main/command.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'main/command.go') diff --git a/main/command.go b/main/command.go index ef48596..5a898e2 100644 --- a/main/command.go +++ b/main/command.go @@ -1,8 +1,8 @@ package main import ( - "main/walk" "main/subex" + "main/walk" "fmt" ) @@ -46,7 +46,7 @@ func (cmd AppendNextCommand) exec(state *ProgramState) { if err != nil { panic("Missing next value") } - state.value = walk.ConcatData(state.value, nextItem.Value) + state.value = append(state.value, nextItem.Value...) state.path = nextItem.Path state.pc++ } @@ -72,12 +72,12 @@ func (cmd DeletePathCommand) String() string { return "D" } -func runSubex(state subex.Transducer, in []walk.Atom) (out []walk.Atom, error bool) { - atomsOut, error := subex.RunTransducer(state, in) +func runSubex(state subex.Transducer, in walk.ValueList) (walk.ValueList, bool) { + out, error := subex.RunTransducer(state, in) if error { return nil, true } - return atomsOut, false + return out, false } type SubstituteValueCommand struct { @@ -193,7 +193,7 @@ func (cmd SwapPathCommand) String() string { type AppendPathCommand struct {} func (cmd AppendPathCommand) exec(state *ProgramState) { - state.path = walk.ConcatData(state.path, state.value) + state.path = append(state.path, state.value...) state.pc++ } func (cmd AppendPathCommand) String() string { -- cgit v1.2.3