Implemented error messages

This commit is contained in:
Eduard Urbach 2024-06-13 12:13:32 +02:00
parent 423526e567
commit e3b26c79f4
Signed by: eduard
GPG key ID: 49226B848C78F6C8
16 changed files with 362 additions and 60 deletions

View file

@ -7,34 +7,20 @@ import (
// Build describes a compiler build.
type Build struct {
Files []string
WriteExecutable bool
Files []string
}
// New creates a new build.
func New(files ...string) *Build {
return &Build{
Files: files,
WriteExecutable: true,
Files: files,
}
}
// Run parses the input files and generates an executable file.
func (build *Build) Run() error {
func (build *Build) Run() (map[string]*Function, error) {
functions, errors := Scan(build.Files)
allFunctions, err := Compile(functions, errors)
if err != nil {
return err
}
if !build.WriteExecutable {
return nil
}
path := build.Executable()
code, data := Finalize(allFunctions)
return Write(path, code, data)
return Compile(functions, errors)
}
// Executable returns the path to the executable.