xgo/compiler/ast/file.go

30 lines
471 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
"strings"
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/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, "; ")
}