forked from cjcodell1/tint
/
buildTM.go
41 lines (34 loc) · 906 Bytes
/
buildTM.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package yaml
import (
"github.com/cjcodell1/tint/machine"
"github.com/cjcodell1/tint/machine/turing/ways/two"
"github.com/cjcodell1/tint/machine/turing/ways/one"
)
type oneWayTmBuilder struct {
// These must be exported, yaml parser requires it.
Start string
Accept string
Reject string
Transitions [][]string
}
func (b oneWayTmBuilder) subBuild() (machine.Machine, error) {
tm, err := one.MakeTuringMachine(b.Transitions, b.Start, b.Accept, b.Reject)
if err != nil {
return nil, err
}
return tm, nil
}
type twoWayTmBuilder struct {
// These must be exported, yaml parser requires it.
Start string
Accept string
Reject string
Transitions [][]string
}
func (b twoWayTmBuilder) subBuild() (machine.Machine, error) {
tm, err := two.MakeTuringMachine(b.Transitions, b.Start, b.Accept, b.Reject)
if err != nil {
return nil, err
}
return tm, nil
}