Documentation ¶
Index ¶
- type Pos
- func (p Pos) AbsFilename() string
- func (p Pos) After(q Pos) bool
- func (p Pos) Base() *PosBase
- func (p Pos) Before(q Pos) bool
- func (x Pos) Col() uint
- func (p Pos) Filename() string
- func (p Pos) IsKnown() bool
- func (x Pos) Line() uint
- func (p Pos) RelFilename() string
- func (p Pos) RelLine() uint
- func (p Pos) String() string
- type PosBase
- type PosTable
- type XPos
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pos ¶
type Pos struct {
// contains filtered or unexported fields
}
A Pos encodes a source position consisting of a (line, column) number pair and a position base. A zero Pos is a ready to use "unknown" position (nil position base and zero line number).
The (line, column) values refer to a position in a file independent of any position base ("absolute" position). Line numbers start at 1, column values start at 0 and are byte offsets from the beginning of the line.
The position base is used to determine the "relative" position, that is the filename and line number relative to the position base. If the base refers to the current file, there is no difference between absolute and relative positions. If it refers to a //line pragma, a relative position is relative to that pragma. A position base in turn contains the position at which it was introduced in the current file.
var NoPos Pos
NoPos is a valid unknown position.
func MakePos ¶
MakePos creates a new Pos value with the given base, and (file-absolute) line and column.
func (Pos) AbsFilename ¶
AbsFilename() returns the absolute filename recorded with the position's base.
func (Pos) After ¶
After reports whether the position p comes after q in the source. For positions in different files, ordering is by filename.
func (Pos) Before ¶
Before reports whether the position p comes before q in the source. For positions in different files, ordering is by filename.
func (Pos) IsKnown ¶
IsKnown reports whether the position p is known. A position is known if it either has a non-nil position base, or a non-zero line number.
func (Pos) RelFilename ¶
RelFilename returns the filename recorded with the position's base.
type PosBase ¶
type PosBase struct {
// contains filtered or unexported fields
}
A PosBase encodes a filename and base line number. Typically, each file and line pragma introduce a PosBase. A nil *PosBase is a ready to use file PosBase for an unnamed file with line numbers starting at 1.
func NewFileBase ¶
NewFileBase returns a new *PosBase for a file with the given (relative and absolute) filenames.
func NewLinePragmaBase ¶
NewLinePragmaBase returns a new *PosBase for a line pragma of the form
//line filename:line
at position pos.
func (*PosBase) AbsFilename ¶
AbsFilename returns the absolute filename recorded with the base. If b == nil, the result is the empty string.
func (*PosBase) Filename ¶
Filename returns the filename recorded with the base. If b == nil, the result is the empty string.
type PosTable ¶
type PosTable struct {
// contains filtered or unexported fields
}
A PosTable tracks Pos -> XPos conversions and vice versa. Its zero value is a ready-to-use PosTable.
type XPos ¶
type XPos struct {
// contains filtered or unexported fields
}
XPos is a more compact representation of Pos.
var NoXPos XPos
NoXPos is a valid unknown position.
func (XPos) After ¶
After reports whether the position p comes after q in the source. For positions with different bases, ordering is by base index.
func (XPos) Before ¶
Before reports whether the position p comes before q in the source. For positions with different bases, ordering is by base index.