Files
subcoding/assembler/parse.go

23 lines
332 B
Go
Raw Normal View History

2021-11-16 21:08:46 -10:00
package assembler
import "gopkg.in/yaml.v2"
2021-11-18 17:43:13 -10:00
type program struct {
Functions []function `yaml:"functions"`
2021-11-16 21:08:46 -10:00
}
2021-11-18 17:43:13 -10:00
type function []instruction
2021-11-16 21:08:46 -10:00
2021-11-18 17:43:13 -10:00
type instruction []string
2021-11-16 21:08:46 -10:00
2021-11-18 17:43:13 -10:00
func parse(src []byte) (*program, error) {
prog := &program{}
err := yaml.UnmarshalStrict(src, &prog)
2021-11-16 21:08:46 -10:00
if err != nil {
return nil, err
}
return prog, nil
}