xgo/compiler/parser/parse_file.go

29 lines
471 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package parser
import (
"io"
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/source"
2019-01-09 10:17:42 +03:00
)
// ParseFile parses a file with a given src.
func ParseFile(file *source.File, src []byte, trace io.Writer) (res *ast.File, err error) {
2019-01-09 10:17:42 +03:00
p := NewParser(file, src, trace)
defer func() {
if e := recover(); e != nil {
if _, ok := e.(bailout); !ok {
panic(e)
}
}
p.errors.Sort()
err = p.errors.Err()
}()
res, err = p.ParseFile()
return
}