Assembler working
This commit is contained in:
@@ -2,24 +2,21 @@ package assembler
|
||||
|
||||
import "gopkg.in/yaml.v2"
|
||||
|
||||
type Program struct {
|
||||
Functions []*Function `yaml:"functions"`
|
||||
type program struct {
|
||||
Functions []function `yaml:"functions"`
|
||||
}
|
||||
|
||||
type Function []*Instruction
|
||||
type Instruction []string
|
||||
type function []instruction
|
||||
|
||||
func NewProgramFromBytes(in []byte) (*Program, error) {
|
||||
prog := &Program{}
|
||||
type instruction []string
|
||||
|
||||
err := yaml.UnmarshalStrict(in, &prog)
|
||||
func parse(src []byte) (*program, error) {
|
||||
prog := &program{}
|
||||
|
||||
err := yaml.UnmarshalStrict(src, &prog)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return prog, nil
|
||||
}
|
||||
|
||||
func NewProgramFromString(in string) (*Program, error) {
|
||||
return NewProgramFromBytes([]byte(in))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user