Documentation ¶
Overview ¶
Abstraction of a position for use by consumers, with a basic implementation.
This interface intentionally makes no provision for updating the position. If it did, compiler implementations would incur two forms of overhead:
- Every query operation on a Position would involve an indirection
- Since positions are intended to be read-only, every advance of a Position would incur an allocation overhead.
The second one is the main concern, because positions are manipulated very frequently in parsers and formatters. The practical consequence is that such tools must provide their own position implementation, such as the one in reader.Pos.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicPos ¶
type BasicPos struct {
// contains filtered or unexported fields
}
A basic position value.
This type exists primarily for testing. It can be used as a starting point, but where performance or space are important you will want a more condensed representation. The one in the reader package is an example.
type Position ¶
type Position interface { fmt.Stringer Filename() string // Return the file name associated with this position. Line() int // Return the line number (starting at 1) of this position. Column() int // Return the column number (starting at 1) of this position. Offset() int // Return the byte offset (starting at 0) of this position. Raw() Position // Return aform of the position that does not take line number directives into account. }
The position abstraction