xgo/parser/parse_file.go

28 lines
410 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package parser
import (
"io"
"github.com/d5/tengo/ast"
"github.com/d5/tengo/scanner"
)
func ParseFile(file *scanner.File, src []byte, trace io.Writer) (res *ast.File, err error) {
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
}