Documentation
¶
Overview ¶
Package runes provides a simpler rune scanner for lexers.
It reads an io.Reader entirely into memory to accomplish this so should only be used where the data can easily fit into memory.
Index ¶
- type Rune
- type Runes
- type Scanner
- func (s *Scanner) Peek(offset ...int) rune
- func (s *Scanner) PeekE(offset ...int) (r Rune, err error)
- func (s *Scanner) PeekPrev(offset ...int) rune
- func (s *Scanner) PeekPrevE(offset ...int) (r Rune, err error)
- func (s *Scanner) Read() rune
- func (s *Scanner) ReadE() (r Rune, err error)
- func (s *Scanner) Readline() (line Runes, err error)
- func (s *Scanner) Size() int
- func (s *Scanner) Unread() rune
- func (s *Scanner) UnreadE() (r Rune, err error)
- func (s *Scanner) Unreadline() (line Runes, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rune ¶
type Rune struct {
Val rune // actual rune
Pos buf.Position // position of the rune as relates to the document
}
Rune wraps a rune with with positioning
type Runes ¶
type Runes struct {
Val []rune // actual runes
Pos buf.Position // position of the first rune as relates to the document
}
Runes wraps a slice of rune with positioning
type Scanner ¶
type Scanner struct {
Pos buf.Position // line, column and offset positioning in document
// contains filtered or unexported fields
}
Scanner provides methods for working with documents as runes
func NewScanner ¶
NewScanner for scanning documents as runes
func (*Scanner) Peek ¶
Peek the rune at the given offset, offset must be positive values, 0 being the current rune; don't adjust positioning
func (*Scanner) PeekE ¶ added in v1.1.34
PeekE the rune at the given offset, offset must be positive values, 0 being the current rune; don't adjust positioning
func (*Scanner) PeekPrev ¶
PeekPrev the rune at the given offset, offset must be positive values, 0 being the previous rune, 1 being the one before the previous; don't adjust positioning
func (*Scanner) PeekPrevE ¶ added in v1.1.34
PeekPrevE the rune at the given offset, offset must be positive values, 0 being the previous rune, 1 being the one before the previous; don't adjust positioning
func (*Scanner) ReadE ¶ added in v1.1.34
ReadE the rune at the current location and adjust positioning
func (*Scanner) Readline ¶
Readline from the rune slice location up to and including the next newline adjusting positioning
func (*Scanner) UnreadE ¶ added in v1.1.34
UnreadE the rune at the current location and adjust positioning
func (*Scanner) Unreadline ¶
Unreadline from the current location back to the previous newline adjusting positioning