Documentation ¶
Index ¶
- Variables
- func ErrorCatcher(errFunc func(error))
- func ParseKV(str string, callback func(string, interface{}) bool) (errRet error)
- type BackTicksMatcher
- type CStyleCommentMatcher
- type IdentifierMatcher
- type KVPair
- func (self *KVPair) ContainKey(key string) bool
- func (self *KVPair) ContainValue(key string, tgt string) bool
- func (self *KVPair) GetBool(key string) bool
- func (self *KVPair) GetString(key string) string
- func (self *KVPair) Parse(str string) error
- func (self *KVPair) Raw() map[string]interface{}
- func (self *KVPair) SetString(key, value string)
- func (self *KVPair) String() string
- type KeywordMatcher
- type Lexer
- func (self *Lexer) AddIgnoreMatcher(m TokenMatcher)
- func (self *Lexer) AddMatcher(m TokenMatcher)
- func (self *Lexer) MatcherByID(id int) TokenMatcher
- func (self *Lexer) MatcherString(id int) string
- func (self *Lexer) Read() (Token, error)
- func (self *Lexer) Start(src string)
- func (self *Lexer) VisitMatcher(callback func(TokenMatcher) bool)
- type LineEndMatcher
- type NumeralMatcher
- type Parser
- func (self *Parser) Expect(id int) Token
- func (self *Parser) Lexer() *Lexer
- func (self *Parser) MatcherName() string
- func (self *Parser) MatcherString() string
- func (self *Parser) NextToken()
- func (self *Parser) PreTokenPos() TokenPos
- func (self *Parser) RawToken() Token
- func (self *Parser) TokenID() int
- func (self *Parser) TokenPos() TokenPos
- func (self *Parser) TokenRaw() string
- func (self *Parser) TokenValue() string
- type SignMatcher
- type StringMatcher
- type Token
- func (self Token) Index() int
- func (self Token) Line() int
- func (self *Token) MatcherID() int
- func (self *Token) MatcherName() string
- func (self *Token) MatcherString() string
- func (self Token) Raw() string
- func (self *Token) String() string
- func (self Token) ToFloat32() float32
- func (self Token) ToInt() int
- func (self Token) ToInt32() int32
- func (self Token) ToInt64() int64
- func (self Token) Value() string
- type TokenMatcher
- func NewBackTicksMatcher(id int) TokenMatcher
- func NewCStyleCommentMatcher(id int) TokenMatcher
- func NewIdentifierMatcher(id int) TokenMatcher
- func NewKeywordMatcher(id int, word string) TokenMatcher
- func NewLineEndMatcher(id int) TokenMatcher
- func NewNumeralMatcher(id int) TokenMatcher
- func NewPositiveNumeralMatcher(id int) TokenMatcher
- func NewSignMatcher(id int, word string) TokenMatcher
- func NewStringMatcher(id int) TokenMatcher
- func NewUnixStyleCommentMatcher(id int) TokenMatcher
- func NewUnknownMatcher(id int) TokenMatcher
- func NewWhiteSpaceMatcher(id int) TokenMatcher
- type TokenPos
- type Tokenizer
- func (self *Tokenizer) ConsumeMulti(count int)
- func (self *Tokenizer) ConsumeOne()
- func (self *Tokenizer) Count() int
- func (self *Tokenizer) Current() rune
- func (self *Tokenizer) EOF() bool
- func (self *Tokenizer) Index() int
- func (self *Tokenizer) Line() int
- func (self *Tokenizer) Peek(offset int) rune
- func (self *Tokenizer) StringRange(begin, end int) string
- type UnixStyleCommentMatcher
- type UnknownMatcher
- type WhiteSpaceMatcher
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTokenPos = TokenPos{Line: 1, Col: 1}
View Source
var EmptyToken = NewToken(nil, nil, "NIL", "")
Functions ¶
func ErrorCatcher ¶
func ErrorCatcher(errFunc func(error))
Types ¶
type BackTicksMatcher ¶
type BackTicksMatcher struct {
// contains filtered or unexported fields
}
字符串
func (*BackTicksMatcher) String ¶
func (self *BackTicksMatcher) String() string
type CStyleCommentMatcher ¶
type CStyleCommentMatcher struct {
// contains filtered or unexported fields
}
#开头的行注释
func (*CStyleCommentMatcher) Match ¶
func (self *CStyleCommentMatcher) Match(tz *Tokenizer) (Token, error)
func (*CStyleCommentMatcher) String ¶
func (self *CStyleCommentMatcher) String() string
type IdentifierMatcher ¶
type IdentifierMatcher struct {
// contains filtered or unexported fields
}
标识符
func (*IdentifierMatcher) Match ¶
func (self *IdentifierMatcher) Match(tz *Tokenizer) (Token, error)
func (*IdentifierMatcher) String ¶
func (self *IdentifierMatcher) String() string
type KVPair ¶
type KVPair struct {
// contains filtered or unexported fields
}
func (*KVPair) ContainKey ¶
type KeywordMatcher ¶
type KeywordMatcher struct {
// contains filtered or unexported fields
}
下划线和字母(中文)+数字=关键字
func (*KeywordMatcher) String ¶
func (self *KeywordMatcher) String() string
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func (*Lexer) AddIgnoreMatcher ¶
func (self *Lexer) AddIgnoreMatcher(m TokenMatcher)
添加一个匹配器,如果结果匹配,直接忽略匹配内容
func (*Lexer) MatcherByID ¶
func (self *Lexer) MatcherByID(id int) TokenMatcher
func (*Lexer) MatcherString ¶
func (*Lexer) VisitMatcher ¶
func (self *Lexer) VisitMatcher(callback func(TokenMatcher) bool)
type LineEndMatcher ¶
type LineEndMatcher struct {
// contains filtered or unexported fields
}
行结束
func (*LineEndMatcher) String ¶
func (self *LineEndMatcher) String() string
type NumeralMatcher ¶
type NumeralMatcher struct {
// contains filtered or unexported fields
}
整形,浮点数
func (*NumeralMatcher) String ¶
func (self *NumeralMatcher) String() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) MatcherName ¶
func (*Parser) MatcherString ¶
func (*Parser) PreTokenPos ¶
func (*Parser) TokenValue ¶
type SignMatcher ¶
type SignMatcher struct {
// contains filtered or unexported fields
}
操作符,分隔符
func (*SignMatcher) String ¶
func (self *SignMatcher) String() string
type StringMatcher ¶
type StringMatcher struct {
// contains filtered or unexported fields
}
字符串
func (*StringMatcher) String ¶
func (self *StringMatcher) String() string
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func (*Token) MatcherName ¶
func (*Token) MatcherString ¶
type TokenMatcher ¶
func NewBackTicksMatcher ¶
func NewBackTicksMatcher(id int) TokenMatcher
func NewCStyleCommentMatcher ¶
func NewCStyleCommentMatcher(id int) TokenMatcher
func NewIdentifierMatcher ¶
func NewIdentifierMatcher(id int) TokenMatcher
func NewKeywordMatcher ¶
func NewKeywordMatcher(id int, word string) TokenMatcher
func NewLineEndMatcher ¶
func NewLineEndMatcher(id int) TokenMatcher
func NewNumeralMatcher ¶
func NewNumeralMatcher(id int) TokenMatcher
func NewPositiveNumeralMatcher ¶
func NewPositiveNumeralMatcher(id int) TokenMatcher
func NewSignMatcher ¶
func NewSignMatcher(id int, word string) TokenMatcher
func NewStringMatcher ¶
func NewStringMatcher(id int) TokenMatcher
func NewUnixStyleCommentMatcher ¶
func NewUnixStyleCommentMatcher(id int) TokenMatcher
func NewUnknownMatcher ¶
func NewUnknownMatcher(id int) TokenMatcher
func NewWhiteSpaceMatcher ¶
func NewWhiteSpaceMatcher(id int) TokenMatcher
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
func NewTokenizer ¶
func (*Tokenizer) ConsumeMulti ¶
func (*Tokenizer) ConsumeOne ¶
func (self *Tokenizer) ConsumeOne()
func (*Tokenizer) StringRange ¶
type UnixStyleCommentMatcher ¶
type UnixStyleCommentMatcher struct {
// contains filtered or unexported fields
}
#开头的行注释
func (*UnixStyleCommentMatcher) Match ¶
func (self *UnixStyleCommentMatcher) Match(tz *Tokenizer) (Token, error)
func (*UnixStyleCommentMatcher) String ¶
func (self *UnixStyleCommentMatcher) String() string
type UnknownMatcher ¶
type UnknownMatcher struct {
// contains filtered or unexported fields
}
未知字符
func (*UnknownMatcher) String ¶
func (self *UnknownMatcher) String() string
type WhiteSpaceMatcher ¶
type WhiteSpaceMatcher struct {
// contains filtered or unexported fields
}
空白字符
func (*WhiteSpaceMatcher) Match ¶
func (self *WhiteSpaceMatcher) Match(tz *Tokenizer) (Token, error)
func (*WhiteSpaceMatcher) String ¶
func (self *WhiteSpaceMatcher) String() string
Source Files ¶
- errcatcher.go
- kvpair.go
- kvparser.go
- lexer.go
- matcher.go
- matcher_backticks.go
- matcher_cstylecomment.go
- matcher_identifier.go
- matcher_keyword.go
- matcher_lineend.go
- matcher_numeral.go
- matcher_sign.go
- matcher_string.go
- matcher_unixstylecomment.go
- matcher_unknown.go
- matcher_whitespace.go
- parser.go
- token.go
- tokenizer.go
- tokenpos.go
Click to show internal directories.
Click to hide internal directories.