tokenStream.go 574 B

123456789101112131415161718192021222324252627282930313233343536
  1. package govaluate
  2. type tokenStream struct {
  3. tokens []ExpressionToken
  4. index int
  5. tokenLength int
  6. }
  7. func newTokenStream(tokens []ExpressionToken) *tokenStream {
  8. var ret *tokenStream
  9. ret = new(tokenStream)
  10. ret.tokens = tokens
  11. ret.tokenLength = len(tokens)
  12. return ret
  13. }
  14. func (this *tokenStream) rewind() {
  15. this.index -= 1
  16. }
  17. func (this *tokenStream) next() ExpressionToken {
  18. var token ExpressionToken
  19. token = this.tokens[this.index]
  20. this.index += 1
  21. return token
  22. }
  23. func (this tokenStream) hasNext() bool {
  24. return this.index < this.tokenLength
  25. }