Documentation ¶
Index ¶
- type LexFn
- type Lexer
- func (this *Lexer) Backup()
- func (this *Lexer) CurrentInput() string
- func (this *Lexer) Dec()
- func (this *Lexer) Emit(tokenType lexertoken.TokenType)
- func (this *Lexer) Errorf(format string, args ...interface{}) LexFn
- func (this *Lexer) Ignore()
- func (this *Lexer) Inc()
- func (this *Lexer) InputToEnd() string
- func (this *Lexer) IsEOF() bool
- func (this *Lexer) IsWhitespace() bool
- func (this *Lexer) Next() rune
- func (this *Lexer) NextToken() lexertoken.Token
- func (this *Lexer) Peek() rune
- func (this *Lexer) Run()
- func (this *Lexer) Shutdown()
- func (this *Lexer) SkipWhitespace()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LexFn ¶
func LexBegin ¶
This lexer function starts everything off. It determines if we are beginning with a key/value assignment or a section.
func LexEqualSign ¶
This lexer function emits a TOKEN_EQUAL_SIGN then returns the lexer for value.
func LexKey ¶
This lexer function emits a TOKEN_KEY with the name of an key that will be assigned a value.
func LexLeftBracket ¶
This lexer function emits a TOKEN_LEFT_BRACKET then returns the lexer for a section header.
func LexRightBracket ¶
This lexer function emits a TOKEN_RIGHT_BRACKET then returns the lexer for a begin.
func LexSection ¶
This lexer function emits a TOKEN_SECTION with the name of an INI file section header.
type Lexer ¶
type Lexer struct { Name string Input string Tokens chan lexertoken.Token State LexFn Start int Pos int Width int }
Lexer object contains the state of our parser and provides a stream for accepting tokens.
Based on work by Rob Pike http://cuddle.googlecode.com/hg/talk/lex.html#landing-slide
func (*Lexer) CurrentInput ¶
Returns a slice of the current input from the current lexer start position to the current position.
func (*Lexer) Emit ¶
func (this *Lexer) Emit(tokenType lexertoken.TokenType)
Puts a token onto the token channel. The value of this token is read from the input based on the current lexer position.
func (*Lexer) Ignore ¶
func (this *Lexer) Ignore()
Ignores the current token by setting the lexer's start position to the current reading position.
func (*Lexer) InputToEnd ¶
Return a slice of the input from the current lexer position to the end of the input string.
func (*Lexer) IsWhitespace ¶
Returns true/false if then next character is whitespace
func (*Lexer) Next ¶
Reads the next rune (character) from the input stream and advances the lexer position.
func (*Lexer) NextToken ¶
func (this *Lexer) NextToken() lexertoken.Token
Return the next token from the channel
func (*Lexer) Peek ¶
Returns the next rune in the stream, then puts the lexer position back. Basically reads the next rune without consuming it.
func (*Lexer) Run ¶
func (this *Lexer) Run()
Starts the lexical analysis and feeding tokens into the token channel.
func (*Lexer) SkipWhitespace ¶
func (this *Lexer) SkipWhitespace()
Skips whitespace until we get something meaningful.