func LoadProjectDir(pd string, scope *rt.Scope) (*rt.Scope, error) { src := pd + "/src" files, err := parse.ParseDir(file.NewFileSet(), src, isLangFile) if err != nil { return nil, err } pfile := filepath.Base(pd) + ".soma" var last string for path, file := range files { if filepath.Base(path) != pfile { file.Visit(scope) } else { last = path } } files[last].Visit(scope) rdefs := libsFromManifest(pd) for _, rdef := range rdefs { rdef.Visit(scope) } return scope, nil }
func initScanner(expr string) scan.Scanner { src := []byte(expr) fset := file.NewFileSet() file := fset.AddFile("", fset.Base(), len(src)) var s scan.Scanner s.Init(file, src, nil) return s }