file.go 575 B

1234567891011121314151617181920212223242526272829
  1. package parser
  2. import (
  3. "strings"
  4. )
  5. // File represents a file unit.
  6. type File struct {
  7. InputFile *SourceFile
  8. Stmts []Stmt
  9. }
  10. // Pos returns the position of first character belonging to the node.
  11. func (n *File) Pos() Pos {
  12. return Pos(n.InputFile.Base)
  13. }
  14. // End returns the position of first character immediately after the node.
  15. func (n *File) End() Pos {
  16. return Pos(n.InputFile.Base + n.InputFile.Size)
  17. }
  18. func (n *File) String() string {
  19. var stmts []string
  20. for _, e := range n.Stmts {
  21. stmts = append(stmts, e.String())
  22. }
  23. return strings.Join(stmts, "; ")
  24. }