Add ParseFile convenience method

This commit is contained in:
Sasha Koshka 2023-09-18 00:24:31 -04:00
parent eb73b388d6
commit ecd222ef42
1 changed files with 8 additions and 0 deletions

View File

@ -59,3 +59,11 @@ func (this *Tree) Parse (name string, file io.Reader) error {
this.Declarations = append(this.Declarations, parsed.Declarations...)
return err
}
// ParseFile parses the contents of the given file into the tree.
func (this *Tree) ParseFile (name string) error {
file, err := os.Open(name)
if err != nil { return err }
defer file.Close()
return this.Parse(name, file)
}