<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-26 11:57:37 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-26 11:57:37 +0100
commit0da98a3d83b5aa6ccae73658ef0692c4023bc70f (patch)
treeb360581836295c21aef03efe5fb6f0d3aeb3f5fc /main
parentc6b1341fab071ab9d9419dace857b826ddf2acf1 (diff)
downloadstred-go-0da98a3d83b5aa6ccae73658ef0692c4023bc70f.tar
Add Y and Z registers
Diffstat (limited to 'main')
-rw-r--r--main/command.go24
-rw-r--r--main/main.go2
-rw-r--r--main/parse.go8
3 files changed, 33 insertions, 1 deletions
diff --git a/main/command.go b/main/command.go
index 9403020..296ad69 100644
--- a/main/command.go
+++ b/main/command.go
@@ -107,6 +107,30 @@ func (cmd AppendXRegCommand) exec(state *ProgramState) {
state.xreg = append(state.xreg, state.value...)
}
+type SwapYRegCommand struct {}
+func (cmd SwapYRegCommand) exec(state *ProgramState) {
+ v := state.value
+ state.value = state.yreg
+ state.yreg = v
+}
+
+type AppendYRegCommand struct {}
+func (cmd AppendYRegCommand) exec(state *ProgramState) {
+ state.yreg = append(state.yreg, state.value...)
+}
+
+type SwapZRegCommand struct {}
+func (cmd SwapZRegCommand) exec(state *ProgramState) {
+ v := state.value
+ state.value = state.zreg
+ state.zreg = v
+}
+
+type AppendZRegCommand struct {}
+func (cmd AppendZRegCommand) exec(state *ProgramState) {
+ state.zreg = append(state.zreg, state.value...)
+}
+
type SwapPathCommand struct {}
func (cmd SwapPathCommand) exec(state *ProgramState) {
v := state.value
diff --git a/main/main.go b/main/main.go
index 0c7324b..2067920 100644
--- a/main/main.go
+++ b/main/main.go
@@ -9,7 +9,7 @@ import (
type Program []Command
type ProgramState struct {
- path, value, xreg []walk.Atom
+ path, value, xreg, yreg, zreg []walk.Atom
in walk.JSONIn
out walk.JSONOut
program []Command
diff --git a/main/parse.go b/main/parse.go
index d31687a..1972b66 100644
--- a/main/parse.go
+++ b/main/parse.go
@@ -142,6 +142,14 @@ func (p *parser) parseBasicCommand(commandChar rune) Command {
return SwapXRegCommand{}
case 'X':
return AppendXRegCommand{}
+ case 'y':
+ return SwapYRegCommand{}
+ case 'Y':
+ return AppendYRegCommand{}
+ case 'z':
+ return SwapZRegCommand{}
+ case 'Z':
+ return AppendZRegCommand{}
case 'k':
return SwapPathCommand{}
case 'K':