<- 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.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/main/command.go b/main/command.go
index 38e1c95..e795333 100644
--- a/main/command.go
+++ b/main/command.go
@@ -138,9 +138,38 @@ func (cmd MergeCommand) String() string {
return "m"
}
-type FullMergeCommand struct {}
+type FullMergeCommand struct {
+ subex subex.Transducer
+}
func (cmd FullMergeCommand) exec(state *ProgramState) {
- panic("Unimplemented")
+ _, notOk := runSubex(cmd.subex, state.value)
+ if notOk || state.end {
+ state.pc++
+ return
+ }
+
+ for {
+ item, err := state.Read()
+ if err != nil {
+ panic("Missing next value")
+ }
+
+ _, nonTerminal := runSubex(cmd.subex, []walk.Value{item.Value})
+
+ state.value = append(
+ state.value[:len(state.value) - 1],
+ walk.Merge(state.value[len(state.value) - 1], item.Value)...
+ )
+
+ if !nonTerminal && item.End {
+ state.prevStart = item.PrevStart
+ state.start = item.Start
+ state.end = item.End
+ state.nextEnd = item.NextEnd
+ state.pc += 2
+ return
+ }
+ }
}
func (cmd FullMergeCommand) String() string {
return "M"