<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/command.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2022-09-21 19:37:02 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2022-09-21 19:37:02 +0100
commit96812b9ea732cc7ae26efce4568c19aec0000abc (patch)
tree7a5f55230ac15648c6b66dfc0870e19a1c12a78b /main/command.go
parentcfbe645715114234510bda068d2f30ffbe208eae (diff)
downloadstred-go-96812b9ea732cc7ae26efce4568c19aec0000abc.tar
Adds some new commands
Diffstat (limited to 'main/command.go')
-rw-r--r--main/command.go20
1 files changed, 16 insertions, 4 deletions
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
}