File: tokenStream.go

package info (click to toggle)
golang-github-casbin-govaluate 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 396 kB
  • sloc: sh: 16; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 523 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package govaluate

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
}