Documentation ¶
Index ¶
- type LexFn
- func LexAnd(lexer *Lexer) LexFn
- func LexBegin(lexer *Lexer) LexFn
- func LexComma(lexer *Lexer) LexFn
- func LexDoubleQuotedString(lexer *Lexer) LexFn
- func LexLeftParenthesis(lexer *Lexer) LexFn
- func LexNot(lexer *Lexer) LexFn
- func LexOr(lexer *Lexer) LexFn
- func LexRegexEqual(lexer *Lexer) LexFn
- func LexRightParenthesis(lexer *Lexer) LexFn
- func LexSha1(lexer *Lexer) LexFn
- func LexSingleQuotedString(lexer *Lexer) LexFn
- func LexStringEqual(lexer *Lexer) LexFn
- type Lexer
- func (lexer *Lexer) EatWhitespaces() rune
- func (lexer *Lexer) Emit(tokenType TokenType)
- func (lexer *Lexer) Errorf(err string) LexFn
- func (lexer *Lexer) HasTokenTypeAt(pos int, tokenType TokenType) bool
- func (lexer *Lexer) IsEOF() bool
- func (lexer *Lexer) Lex() []error
- func (lexer *Lexer) Read() rune
- func (lexer *Lexer) RemainingInput() string
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LexFn ¶
LexFn is an interface that lexing functions have to implement
func LexBegin ¶
LexBegin skips all whitespaces and returns a function that can lex the remaining input
func LexDoubleQuotedString ¶
LexDoubleQuotedString emits TokenDoubleQuotedStringLiteral
func LexLeftParenthesis ¶
LexLeftParenthesis emits TokenLeftParenthesis
func LexRightParenthesis ¶
LexRightParenthesis emits TokenRightParenthesis
func LexSingleQuotedString ¶
LexSingleQuotedString emits TokenSingleQuotedStringLiteral
type Lexer ¶
type Lexer struct { Input string Tokens []Token State LexFn Errors []error TokenStart int Position int OpenParenthesisCount int }
Lexer is a structure that contains current state of the lexer
func (*Lexer) EatWhitespaces ¶
EatWhitespaces skips all whitespaces
func (*Lexer) Errorf ¶
Errorf appends error with the given error message to the list of lexer errors
func (*Lexer) HasTokenTypeAt ¶
HasTokenTypeAt returns true if the lexer recognized given token type at the given position
func (*Lexer) RemainingInput ¶
RemainingInput returns a string of an unread remainder input string
type Token ¶
Token is a structure that contains type of recognized token and it's value if applicable
type TokenType ¶
type TokenType int
TokenType represents a type of recognized token
const ( // TokenEOF is an End of File token TokenEOF TokenType = iota // TokenLeftParenthesis is a left parenthesis token TokenLeftParenthesis // TokenRightParenthesis is a right parenthesis token TokenRightParenthesis // TokenComma is a comma token TokenComma // TokenRegexEqual is a regex equal operator token TokenRegexEqual // TokenStringEqual is a string equal operator token TokenStringEqual // TokenNot is a negation logical operator token TokenNot // TokenAnd is an and logical operator token TokenAnd // TokenOr is an or logical operator token TokenOr // TokenSingleQuotedStringLiteral is a single quoted string literal token TokenSingleQuotedStringLiteral // TokenDoubleQuotedStringLiteral is a double quoted string literal token TokenDoubleQuotedStringLiteral // TokenSha1 is a sha1 function token TokenSha1 )