5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-28 19:25:38 +00:00
matterbridge/vendor/github.com/d5/tengo/compiler/parser/parse_file.go

29 lines
471 B
Go
Raw Normal View History

package parser
import (
"io"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/source"
)
// ParseFile parses a file with a given src.
func ParseFile(file *source.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
}