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 {
|
2019-01-11 12:16:34 +03:00
|
|
|
InputFile *source.File
|
2019-01-09 10:17:42 +03:00
|
|
|
Stmts []Stmt
|
|
|
|
}
|
|
|
|
|
2019-01-11 12:16:34 +03:00
|
|
|
func (n *File) Pos() source.Pos {
|
|
|
|
return source.Pos(n.InputFile.Base())
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|
|
|
|
|
2019-01-11 12:16:34 +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, "; ")
|
|
|
|
}
|