matterbridge/vendor/github.com/d5/tengo/compiler/parser/parse_source.go

18 lines
401 B
Go
Raw Normal View History

package parser
import (
"io"
"github.com/d5/tengo/compiler/ast"
"github.com/d5/tengo/compiler/source"
)
// ParseSource parses source code 'src' and builds an AST.
func ParseSource(filename string, src []byte, trace io.Writer) (res *ast.File, err error) {
fileSet := source.NewFileSet()
file := fileSet.AddFile(filename, -1, len(src))
2019-03-05 14:08:54 -08:00
p := NewParser(file, src, trace)
return p.ParseFile()
}