xgo/ast/file.go

30 lines
462 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
"github.com/d5/tengo/source"
2019-01-09 10:17:42 +03:00
)
type File struct {
InputFile *source.File
2019-01-09 10:17:42 +03:00
Stmts []Stmt
}
func (n *File) Pos() source.Pos {
return source.Pos(n.InputFile.Base())
2019-01-09 10:17:42 +03:00
}
func (n *File) End() source.Pos {
return source.Pos(n.InputFile.Base() + n.InputFile.Size())
2019-01-09 10:17:42 +03:00
}
func (n *File) String() string {
var stmts []string
for _, e := range n.Stmts {
stmts = append(stmts, e.String())
}
return strings.Join(stmts, "; ")
}