From 96812b9ea732cc7ae26efce4568c19aec0000abc Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 21 Sep 2022 19:37:02 +0100 Subject: Adds some new commands --- main/command.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'main/command.go') diff --git a/main/command.go b/main/command.go index bad5b1e..91cb5e4 100644 --- a/main/command.go +++ b/main/command.go @@ -47,10 +47,10 @@ func (cmd SequenceCommand) exec(state *ProgramState) { } } -type AppendCommand struct { +type AppendLiteralCommand struct { values []WalkValue } -func (cmd AppendCommand) exec(state *ProgramState) { +func (cmd AppendLiteralCommand) exec(state *ProgramState) { for _, value := range cmd.values { state.space = append(state.space, WalkItem { path: nil, @@ -59,10 +59,10 @@ func (cmd AppendCommand) exec(state *ProgramState) { } } -type PrependCommand struct { +type PrependLiteralCommand struct { values []WalkValue } -func (cmd PrependCommand) exec(state *ProgramState) { +func (cmd PrependLiteralCommand) exec(state *ProgramState) { var newItems []WalkItem for _, value := range cmd.values { newItems = append(newItems, WalkItem { @@ -73,6 +73,18 @@ func (cmd PrependCommand) exec(state *ProgramState) { state.space = append(newItems, state.space...) } +type NextCommand struct {} +func (cmd NextCommand) exec(state *ProgramState) { + nextItem := <- state.in + state.space = []WalkItem{nextItem} +} + +type AppendNextCommand struct {} +func (cmd AppendNextCommand) exec(state *ProgramState) { + nextItem := <- state.in + state.space = append(state.space, nextItem) +} + type PrintLiteralsCommand struct { items []WalkItem } -- cgit v1.2.3