Home | History | Annotate | Download | only in token

Lines Matching defs:Pos

28 func (pos *Position) IsValid() bool { return pos.Line > 0 }
37 func (pos Position) String() string {
38 s := pos.Filename
39 if pos.IsValid() {
43 s += fmt.Sprintf("%d:%d", pos.Line, pos.Column)
51 // Pos is a compact encoding of a source position within a file set.
55 // The Pos value for a given file is a number in the range [base, base+size],
59 // To create the Pos value for a specific source offset (measured in bytes),
61 // and then call File.Pos(offset) for that file. Given a Pos value p
65 // Pos values can be compared directly with the usual comparison operators:
66 // If two Pos values p and q are in the same file, comparing p and q is
71 type Pos int
73 // The zero value for Pos is NoPos; there is no file and line information
75 // smaller than any other Pos value. The corresponding Position value
78 const NoPos Pos = 0
81 func (p Pos) IsValid() bool {
94 base int // Pos value range for this file is [base...base+size]
233 // Pos returns the Pos value for the given file offset;
235 // f.Pos(f.Offset(p)) == p.
237 func (f *File) Pos(offset int) Pos {
241 return Pos(f.base + offset)
245 // p must be a valid Pos value in that file.
246 // f.Offset(f.Pos(offset)) == offset.
248 func (f *File) Offset(p Pos) int {
250 panic("illegal Pos value")
256 // p must be a Pos value in that file or NoPos.
258 func (f *File) Line(p Pos) int {
290 func (f *File) position(p Pos, adjusted bool) (pos Position) {
292 pos.Offset = offset
293 pos.Filename, pos.Line, pos.Column = f.unpack(offset, adjusted)
300 // p must be a Pos value in f or NoPos.
302 func (f *File) PositionFor(p Pos, adjusted bool) (pos Position) {
305 panic("illegal Pos value")
307 pos = f.position(p, adjusted)
315 func (f *File) Position(p Pos) (pos Position) {
359 // exists between a Pos value p for a given file offset offs:
364 // For convenience, File.Pos may be used to create file-specific position
380 panic("token.Pos offset overflow (> 2G of source code in file set)")
410 func (s *FileSet) file(p Pos) *File {
437 func (s *FileSet) File(p Pos) (f *File) {
444 // PositionFor converts a Pos p in the fileset into a Position value.
447 // p must be a Pos value in s or NoPos.
449 func (s *FileSet) PositionFor(p Pos, adjusted bool) (pos Position) {
458 // Position converts a Pos p in the fileset into a Position value.
461 func (s *FileSet) Position(p Pos) (pos Position) {