Documentation ¶
Overview ¶
Package scanner is a token scanner tailored to this library.
BUG(sw) this could probably be almost completely replaced with stdlib's text/scanner.
Index ¶
- type Scanner
- func (l *Scanner) Advance(count int) error
- func (l *Scanner) Chomp()
- func (l *Scanner) Expect(token string) (string, error)
- func (l *Scanner) FindToken(token string, caseSensitive bool) bool
- func (l *Scanner) Peek() (rune, error)
- func (l *Scanner) Pop() (rune, error)
- func (l *Scanner) Pos() int
- func (l *Scanner) Until(r rune) (string, error)
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is a token scanner.
func NewScanner ¶
NewScanner creates a new scanner with the given source.
func (*Scanner) Expect ¶
Expect tells the scanner that the given token must be found at the current position, and consumes it.
If it is not found, it will return an error and the scanner position will not change.
func (*Scanner) FindToken ¶
FindToken returns true if it finds the at the current position, and false otherwise. It does not consume the token.
FindToken will perform a case-insensitive match if caseSensitive = false.
func (*Scanner) Peek ¶
Peek returns the next rune without consuming it. It returns io.EOF if the scanner is at the end of the source.
Notes ¶
Bugs ¶
this could probably be almost completely replaced with stdlib's text/scanner.