2019-12-24 18:42:30 +03:00
|
|
|
package parser
|
2019-01-09 10:17:42 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2019-01-15 09:24:33 +03:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2019-01-15 09:24:33 +03:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2019-01-15 09:24:33 +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, "; ")
|
|
|
|
}
|