<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/command.go
diff options
context:
space:
mode:
Diffstat (limited to 'main/command.go')
-rw-r--r--main/command.go40
1 files changed, 22 insertions, 18 deletions
diff --git a/main/command.go b/main/command.go
index 91cb5e4..c61b0cd 100644
--- a/main/command.go
+++ b/main/command.go
@@ -1,5 +1,9 @@
package main
+import (
+ "main/walk"
+)
+
type PrintValueCommand struct {}
func (cmd PrintValueCommand) exec(state *ProgramState) {
for _, item := range state.space {
@@ -9,19 +13,19 @@ func (cmd PrintValueCommand) exec(state *ProgramState) {
type ToggleTerminalCommand struct {}
func (cmd ToggleTerminalCommand) exec(state *ProgramState) {
- toggled := map[TerminalValue]TerminalValue {
- ArrayBegin: MapBegin,
- ArrayEnd: MapEnd,
- MapBegin: ArrayBegin,
- MapEnd: ArrayEnd,
+ toggled := map[walk.TerminalValue]walk.TerminalValue {
+ walk.ArrayBegin: walk.MapBegin,
+ walk.ArrayEnd: walk.MapEnd,
+ walk.MapBegin: walk.ArrayBegin,
+ walk.MapEnd: walk.ArrayEnd,
}
for i := range state.space {
- terminal, isTerminal := state.space[i].value.(TerminalValue)
+ terminal, isTerminal := state.space[i].Value.(walk.TerminalValue)
if !isTerminal {
continue
}
- state.space[i].value = toggled[terminal]
+ state.space[i].Value = toggled[terminal]
}
}
@@ -48,26 +52,26 @@ func (cmd SequenceCommand) exec(state *ProgramState) {
}
type AppendLiteralCommand struct {
- values []WalkValue
+ values []walk.WalkValue
}
func (cmd AppendLiteralCommand) exec(state *ProgramState) {
for _, value := range cmd.values {
- state.space = append(state.space, WalkItem {
- path: nil,
- value: value,
+ state.space = append(state.space, walk.WalkItem {
+ Path: nil,
+ Value: value,
})
}
}
type PrependLiteralCommand struct {
- values []WalkValue
+ values []walk.WalkValue
}
func (cmd PrependLiteralCommand) exec(state *ProgramState) {
- var newItems []WalkItem
+ var newItems []walk.WalkItem
for _, value := range cmd.values {
- newItems = append(newItems, WalkItem {
- path: nil,
- value: value,
+ newItems = append(newItems, walk.WalkItem {
+ Path: nil,
+ Value: value,
})
}
state.space = append(newItems, state.space...)
@@ -76,7 +80,7 @@ func (cmd PrependLiteralCommand) exec(state *ProgramState) {
type NextCommand struct {}
func (cmd NextCommand) exec(state *ProgramState) {
nextItem := <- state.in
- state.space = []WalkItem{nextItem}
+ state.space = []walk.WalkItem{nextItem}
}
type AppendNextCommand struct {}
@@ -86,7 +90,7 @@ func (cmd AppendNextCommand) exec(state *ProgramState) {
}
type PrintLiteralsCommand struct {
- items []WalkItem
+ items []walk.WalkItem
}
func (cmd PrintLiteralsCommand) exec(state *ProgramState) {
for _, item := range cmd.items {