Documentation ¶
Overview ¶
Package lexer 提供基本的分词功能
Index ¶
- type Lexer
- func (l *Lexer) All() []byte
- func (l *Lexer) AtEOF() bool
- func (l *Lexer) Bytes(start, end int) []byte
- func (l *Lexer) Current() Position
- func (l *Lexer) Delim(delim rune, contain bool) ([]byte, bool)
- func (l *Lexer) DelimFunc(f func(r rune) bool, contain bool) ([]byte, bool)
- func (l *Lexer) DelimString(delim string, contain bool) ([]byte, bool)
- func (l *Lexer) Match(word string) bool
- func (l *Lexer) Move(p Position)
- func (l *Lexer) Next(n int) []byte
- func (l *Lexer) Rollback()
- func (l *Lexer) Spaces(exclude rune) []byte
- type Position
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
Lexer 是对一个文本内容的包装,方便 blocker 等接口操作。
func (*Lexer) DelimFunc ¶
DelimFunc 查找并返回当前位置到 f 确定位置的所有内容
contain 表示是否包含字符本身,如果为 false,则返回内容不包含,且该字符会退回至输入流中,等待下次被读取。
NOTE: 可回滚此操作
func (*Lexer) DelimString ¶
DelimString 查找 delim 并返回到此字符的所有内容
contain 表示是否包含 delim 本身,如果为 false,则返回内容不包含,且该字符串会退回至输入流中,等待下次被读取。
NOTE: 可回滚此操作
Click to show internal directories.
Click to hide internal directories.