Documentation
¶
Overview ¶
Package lex implements common lexing utilities.
Index ¶
- type Position
- type RuneScanner
- func (rs *RuneScanner) AdvanceIf(runes string, ranges ...*unicode.RangeTable) bool
- func (rs *RuneScanner) AdvanceWhile(runes string, ranges ...*unicode.RangeTable) bool
- func (rs *RuneScanner) AdvanceWhileNot(runes string, ranges ...*unicode.RangeTable) bool
- func (rs *RuneScanner) Clear()
- func (rs *RuneScanner) Index() int
- func (rs *RuneScanner) Peek() rune
- func (rs *RuneScanner) Position(n int) Position
- func (rs *RuneScanner) Rune() rune
- func (rs *RuneScanner) Runes() []rune
- func (rs *RuneScanner) Seek(n int)
- func (rs *RuneScanner) Unrune()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RuneScanner ¶
type RuneScanner struct { Err error // contains filtered or unexported fields }
func NewRuneScanner ¶
func NewRuneScanner(r io.Reader) *RuneScanner
NewLexer creates a lexer that reads runes from r.
func (*RuneScanner) AdvanceIf ¶
func (rs *RuneScanner) AdvanceIf(runes string, ranges ...*unicode.RangeTable) bool
AdvanceIf reads a matching rune and returns true, or else leaves rs where it was and returns false.
func (*RuneScanner) AdvanceWhile ¶
func (rs *RuneScanner) AdvanceWhile(runes string, ranges ...*unicode.RangeTable) bool
AdvanceWhile reads matching runes until EOF or a non-matching rune is found, rewinds one step, and finally returns true if and only if at least one matching rune was found.
func (*RuneScanner) AdvanceWhileNot ¶
func (rs *RuneScanner) AdvanceWhileNot(runes string, ranges ...*unicode.RangeTable) bool
AdvanceWhile reads non-matching runes until EOF or a matching rune is found, rewinds one step, and finally returns true if and only if at least one non-matching rune was found.
func (*RuneScanner) Clear ¶
func (rs *RuneScanner) Clear()
func (*RuneScanner) Index ¶
func (rs *RuneScanner) Index() int
func (*RuneScanner) Peek ¶
func (rs *RuneScanner) Peek() rune
Peek returns the rune that would be returned from a subsequent call to Rune.
func (*RuneScanner) Position ¶
func (rs *RuneScanner) Position(n int) Position
Position returns the position of the rune at position n within the current buffer, and supports negative indexing from the end. Panics if abs(n)>=rs.Size().
func (*RuneScanner) Rune ¶
func (rs *RuneScanner) Rune() rune
Rune reads and returns the next available rune.
func (*RuneScanner) Runes ¶
func (rs *RuneScanner) Runes() []rune
func (*RuneScanner) Seek ¶
func (rs *RuneScanner) Seek(n int)
func (*RuneScanner) Unrune ¶
func (rs *RuneScanner) Unrune()
Unrune moves backward by one in the rune buffer of runes that have been read, such that a subsequent call to Rune will re-read a rune that was read before. Panics if the rune buffer is empty.