2019-01-11 12:16:34 +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-11 12:16:34 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// ParseSource parses source code 'src' and builds an AST.
|
2019-02-21 03:26:11 +03:00
|
|
|
func ParseSource(filename string, src []byte, trace io.Writer) (res *ast.File, err error) {
|
2019-01-11 12:16:34 +03:00
|
|
|
fileSet := source.NewFileSet()
|
2019-02-21 03:26:11 +03:00
|
|
|
file := fileSet.AddFile(filename, -1, len(src))
|
2019-01-11 12:16:34 +03:00
|
|
|
|
2019-02-26 09:52:08 +03:00
|
|
|
p := NewParser(file, src, trace)
|
|
|
|
return p.ParseFile()
|
2019-01-11 12:16:34 +03:00
|
|
|
}
|