1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-23 11:10:58 +00:00
Beego/vendor/github.com/Knetic/govaluate/lexerStream.go
2018-11-09 12:37:28 +08:00

40 lines
648 B
Go

package govaluate
type lexerStream struct {
source []rune
position int
length int
}
func newLexerStream(source string) *lexerStream {
var ret *lexerStream
var runes []rune
for _, character := range source {
runes = append(runes, character)
}
ret = new(lexerStream)
ret.source = runes
ret.length = len(runes)
return ret
}
func (this *lexerStream) readCharacter() rune {
var character rune
character = this.source[this.position]
this.position += 1
return character
}
func (this *lexerStream) rewind(amount int) {
this.position -= amount
}
func (this lexerStream) canRead() bool {
return this.position < this.length
}