3500c686b3
- add type infos to VM error messages - add 'Name' to UserFunction objects - add 'expectErrorString' to VM tests - replace vm.expectError() with vm.expectErrorString() to make it more explicit - add source map info to VM error messages - optimization in function calls - add file/line/col info to compiler errors - change stdlib module to be loaded from VM (instead of compiler) so they can be properly loaded after the source is compiled into binary - VM can take builtin modules optionally
16 lines
381 B
Go
16 lines
381 B
Go
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))
|
|
|
|
return ParseFile(file, src, trace)
|
|
}
|