5 // Pos describes an arbitrary source position
6 // including the file, line, and column location.
7 // A Position is valid if the line number is > 0.
9 Filename string // filename, if any
10 Offset int // offset, starting at 0
11 Line int // line number, starting at 1
12 Column int // column number, starting at 1 (character count)
15 // IsValid returns true if the position is valid.
16 func (p *Pos) IsValid() bool { return p.Line > 0 }
18 // String returns a string in one of several forms:
20 // file:line:column valid position with file name
21 // line:column valid position without file name
22 // file invalid position with file name
23 // - invalid position without file name
24 func (p Pos) String() string {
30 s += fmt.Sprintf("%d:%d", p.Line, p.Column)
38 // Before reports whether the position p is before u.
39 func (p Pos) Before(u Pos) bool {
40 return u.Offset > p.Offset || u.Line > p.Line
43 // After reports whether the position p is after u.
44 func (p Pos) After(u Pos) bool {
45 return u.Offset < p.Offset || u.Line < p.Line