Assembler working

This commit is contained in:
Ian Gulliver
2021-11-18 17:43:13 -10:00
parent 6de2e87342
commit bacbcc38d8
6 changed files with 190 additions and 32 deletions

View File

@@ -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))
}