mirror of
https://github.com/hanzoai/eval.git
synced 2026-09-30 21:47:09 +00:00
Module path renamed to github.com/hanzoai/eval and the Go package renamed from govaluate to eval. Evaluation, parsing, lexing, and operator behavior are unchanged; MIT license and George Lester attribution retained. See NOTICE for lineage.
31 lines
518 B
Go
31 lines
518 B
Go
package eval
|
|
|
|
type tokenStream struct {
|
|
tokens []ExpressionToken
|
|
index int
|
|
tokenLength int
|
|
}
|
|
|
|
func newTokenStream(tokens []ExpressionToken) *tokenStream {
|
|
ret := new(tokenStream)
|
|
ret.tokens = tokens
|
|
ret.tokenLength = len(tokens)
|
|
return ret
|
|
}
|
|
|
|
func (this *tokenStream) rewind() {
|
|
this.index -= 1
|
|
}
|
|
|
|
func (this *tokenStream) next() ExpressionToken {
|
|
token := this.tokens[this.index]
|
|
|
|
this.index += 1
|
|
return token
|
|
}
|
|
|
|
func (this tokenStream) hasNext() bool {
|
|
|
|
return this.index < this.tokenLength
|
|
}
|