xgo/parser/file.go

30 lines
575 B
Go
Raw Normal View History

package parser
2019-01-09 10:17:42 +03:00
import (
"strings"
)
// File represents a file unit.
2019-01-09 10:17:42 +03:00
type File struct {
2019-12-20 22:40:38 +03:00
InputFile *SourceFile
2019-01-09 10:17:42 +03:00
Stmts []Stmt
}
// Pos returns the position of first character belonging to the node.
2019-12-20 22:40:38 +03:00
func (n *File) Pos() Pos {
return Pos(n.InputFile.Base)
2019-01-09 10:17:42 +03:00
}
// End returns the position of first character immediately after the node.
2019-12-20 22:40:38 +03:00
func (n *File) End() Pos {
return 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, "; ")
}