// Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message.
192037
func (l *Lexer) Next() (TokenType, []byte) {
	switch l.r.Peek(0) {
	case ' ', '\t', '\n', '\r', '\f':
		l.r.Move(1)
		for l.consumeWhitespace() {
		}
		return WhitespaceToken, l.r.Shift()
	case ':':
		l.r.Move(1)
		return ColonToken, l.r.Shift()
	case ';':
		l.r.Move(1)
		return SemicolonToken, l.r.Shift()
	case ',':
		l.r.Move(1)
		return CommaToken, l.r.Shift()
	case '(', ')', '[', ']', '{', '}':
		if t := l.consumeBracket(); t != ErrorToken {
			return t, l.r.Shift()
		}
	case '#':
		if l.consumeHashToken() {
			return HashToken, l.r.Shift()
		}
	case '"', '\'':
		if t := l.consumeString(); t != ErrorToken {
			return t, l.r.Shift()
		}
	case '.', '+':
		if t := l.consumeNumeric(); t != ErrorToken {
			return t, l.r.Shift()
		}
	case '-':
		if t := l.consumeNumeric(); t != ErrorToken {
			return t, l.r.Shift()
		} else if t := l.consumeIdentlike(); t != ErrorToken {
			return t, l.r.Shift()
		} else if l.consumeCDCToken() {
			return CDCToken, l.r.Shift()
		} else if l.consumeCustomVariableToken() {
			return CustomPropertyNameToken, l.r.Shift()
		}
	case '@':
		if l.consumeAtKeywordToken() {
			return AtKeywordToken, l.r.Shift()
		}
	case '$', '*', '^', '~':
		if t := l.consumeMatch(); t != ErrorToken {
			return t, l.r.Shift()
		}
	case '/':
		if l.consumeComment() {
			return CommentToken, l.r.Shift()
		}
	case '<':
		if l.consumeCDOToken() {
			return CDOToken, l.r.Shift()
		}
	case '\\':
		if t := l.consumeIdentlike(); t != ErrorToken {
			return t, l.r.Shift()
		}
	case 'u', 'U':
		if l.consumeUnicodeRangeToken() {
			return UnicodeRangeToken, l.r.Shift()
		} else if t := l.consumeIdentlike(); t != ErrorToken {
			return t, l.r.Shift()
		}
	case '|':
		if t := l.consumeMatch(); t != ErrorToken {
			return t, l.r.Shift()
		} else if l.consumeColumnToken() {
			return ColumnToken, l.r.Shift()
		}
	case 0:
		if l.r.Err() != nil {
			return ErrorToken, nil
		}
	default:
		if t := l.consumeNumeric(); t != ErrorToken {
			return t, l.r.Shift()
		} else if t := l.consumeIdentlike(); t != ErrorToken {
			return t, l.r.Shift()
		}
	}
	// can't be rune because consumeIdentlike consumes that as an identifier
	l.r.Move(1)
	return DelimToken, l.r.Shift()
}
861623
func (z *Tokenizer) Next() TokenType {
	z.raw.start = z.raw.end
	z.data.start = z.raw.end
	z.data.end = z.raw.end
	if z.err != nil {
		z.tt = ErrorToken
		return z.tt
	}
	if z.rawTag != "" {
		if z.rawTag == "plaintext" {
			// Read everything up to EOF.
			for z.err == nil {
				z.readByte()
			}
			z.data.end = z.raw.end
			z.textIsRaw = true
		} else {
			z.readRawOrRCDATA()
		}
		if z.data.end > z.data.start {
			z.tt = TextToken
			z.convertNUL = true
			return z.tt
		}
	}
	z.textIsRaw = false
	z.convertNUL = false

loop:
	for {
		c := z.readByte()
		if z.err != nil {
			break loop
		}
		if c != '<' {
			continue loop
		}

		// Check if the '<' we have just read is part of a tag, comment
		// or doctype. If not, it's part of the accumulated text token.
		c = z.readByte()
		if z.err != nil {
			break loop
		}
		var tokenType TokenType
		switch {
		case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z':
			tokenType = StartTagToken
		case c == '/':
			tokenType = EndTagToken
		case c == '!' || c == '?':
			// We use CommentToken to mean any of "<!--actual comments-->",
			// "<!DOCTYPE declarations>" and "<?xml processing instructions?>".
			tokenType = CommentToken
		default:
			// Reconsume the current character.
			z.raw.end--
			continue
		}

		// We have a non-text token, but we might have accumulated some text
		// before that. If so, we return the text first, and return the non-
		// text token on the subsequent call to Next.
		if x := z.raw.end - len("<a"); z.raw.start < x {
			z.raw.end = x
			z.data.end = x
			z.tt = TextToken
			return z.tt
		}
		switch tokenType {
		case StartTagToken:
			z.tt = z.readStartTag()
			return z.tt
		case EndTagToken:
			c = z.readByte()
			if z.err != nil {
				break loop
			}
			if c == '>' {
				// "</>" does not generate a token at all. Generate an empty comment
				// to allow passthrough clients to pick up the data using Raw.
				// Reset the tokenizer state and start again.
				z.tt = CommentToken
				return z.tt
			}
			if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' {
				z.readTag(false)
				if z.err != nil {
					z.tt = ErrorToken
				} else {
					z.tt = EndTagToken
				}
				return z.tt
			}
			z.raw.end--
			z.readUntilCloseAngle()
			z.tt = CommentToken
			return z.tt
		case CommentToken:
			if c == '!' {
				z.tt = z.readMarkupDeclaration()
				return z.tt
			}
			z.raw.end--
			z.readUntilCloseAngle()
			z.tt = CommentToken
			return z.tt
		}
	}
	if z.raw.start < z.raw.end {
		z.data.end = z.raw.end
		z.tt = TextToken
		return z.tt
	}
	z.tt = ErrorToken
	return z.tt
}
1025061
func (p *textParser) next() *token {
	if p.backed || p.done {
		p.backed = false
		return &p.cur
	}
	p.advance()
	if p.done {
		p.cur.value = ""
	} else if len(p.cur.value) > 0 && p.cur.value[0] == '"' {
		// Look for multiple quoted strings separated by whitespace,
		// and concatenate them.
		cat := p.cur
		for {
			p.skipWhitespace()
			if p.done || p.s[0] != '"' {
				break
			}
			p.advance()
			if p.cur.err != nil {
				return &p.cur
			}
			cat.value += " " + p.cur.value
			cat.unquoted += p.cur.unquoted
		}
		p.done = false // parser may have seen EOF, but we want to return cat
		p.cur = cat
	}
	return &p.cur
}
544841
func (k *k8sWatcher) Next() (*registry.Result, error) {
	r, ok := <-k.next
	if !ok {
		return nil, errors.New("result chan closed")
	}
	return r, nil
}
1026645
func (d *Decoder) Next() bool {
	d.i += 1

	if d.i >= d.n {
		d.read()
	}

	return len(d.bytes) >= 8 || (d.i >= 0 && d.i < d.n)
}
467953
func (e *CElement) Next() *CElement {
	e.mtx.RLock()
	val := e.next
	e.mtx.RUnlock()
	return val
}
1035413
func (e *StreamAggExec) Next(ctx context.Context, req *chunk.RecordBatch) error {
	if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
		span1 := span.Tracer().StartSpan("streamAgg.Next", opentracing.ChildOf(span.Context()))
		defer span1.Finish()
	}
	if e.runtimeStats != nil {
		start := time.Now()
		defer func() { e.runtimeStats.Record(time.Since(start), req.NumRows()) }()
	}
	req.Reset()
	for !e.executed && !req.IsFull() {
		err := e.consumeOneGroup(ctx, req.Chunk)
		if err != nil {
			e.executed = true
			return err
		}
	}
	return nil
}
375962
func (m *MergeIterator) Next() error {
	// move all the current low iterators to next
	for _, vi := range m.lowIdxs {
		err := m.itrs[vi].Next()
		if err != nil && err != ErrIteratorDone {
			return err
		}
		m.currKs[vi], m.currVs[vi] = m.itrs[vi].Current()
	}
	m.updateMatches()
	if m.lowK == nil {
		return ErrIteratorDone
	}
	return nil
}
641856
func (i *Int) Next() int {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment++
	return i.increment
}
821552
func (e *BooleanDecoder) Next() bool {
	if e.err != nil {
		return false
	}

	e.i++
	return e.i < e.n
}
1005679
func (it *HistoryIterator) Next() (string, *token.TokenTransaction, error) {
	if it.current >= len(it.keys) {
		return "", nil, io.EOF
	}

	txID := it.keys[it.current]
	it.current++
	tx, err := it.pool.TxByID(txID)

	return txID, tx, err
}
142068
func (rows *Rows) Next() bool {
	if rows.lastError == nil && rows.rows != nil {
		hasNext := rows.rows.Next()
		if !hasNext {
			rows.lastError = sql.ErrNoRows
		}
		return hasNext
	}
	return false
}
290069
func (d *Dispenser) Next() bool {
	if d.cursor < len(d.tokens)-1 {
		d.cursor++
		return true
	}
	return false
}
1272063
func nextToken(index int, input []rune) (newIndex int, token Token, err error) {
	var r rune
	var escaped bool

	newIndex, r, escaped, err = nextRune(index, input)
	if err != nil {
		return
	}

	if !escaped {
		if ttype, ok := tokenTypeRunes[r]; ok {
			switch ttype {
			case TTDot:
				token = NewDot()

			case TTSet:
				if r == ']' {
					err = errors.Wrap(ErrInvalidInput, invalidInputMessage(input, newIndex, "set-close ']' with no preceding '['"))
					return
				}

				newIndex, token, err = nextTokenSet(newIndex, input)
				if err != nil {
					return
				}

			default:
				panic(errors.Wrapf(errBadImplementation, "encountered unhandled token type: %v", ttype))
			}

		} else if _, ok := flagRunes[r]; ok {
			err = errors.Wrap(ErrInvalidInput, invalidInputMessage(input, newIndex, "flag '%s' must be preceded by a non-flag", string(r)))
			return

		} else if m, ok := modifierRunes[r]; ok {
			panic(errors.Wrapf(errBadImplementation, "encountered unhandled modifier: %v", m))
		} else {
			// Nothing special to do.
			token = NewCharacter(r)
		}
	} else {
		// Nothing special to do.
		token = NewCharacter(r)
	}

	var f Flag
	newIndex, f, err = nextFlag(newIndex, input)
	if err == errEndOfInput {
		// Let this err be passed in the next cycle, after the current token is consumed.
		err = nil
	} else if err != nil {
		return
	}

	token.SetFlag(f)

	return
}
463921
func (d *decoder) next() {
	// If there's not buffered line
	if d.buffered == "" {
		res := d.scanner.Scan()
		if true != res {
			d.err = d.scanner.Err()
			return
		}
		d.line++
		d.current = d.scanner.Text()
	} else {
		d.current = d.buffered
		d.buffered = ""
	}

	for d.scanner.Scan() {
		d.line++
		line := d.scanner.Text()
		if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") {
			d.current = d.current + line[1:]
		} else {
			// If is not a continuation line, buffer it, for the
			// next call.
			d.buffered = line
			break
		}
	}

	d.err = d.scanner.Err()

	if d.nextFn != nil {
		d.nextFn(d)
	}
}
1252796
func (l *ReaderLexer) Next() (r rune) {
	/* Illustrated guide to how the cursors move:

	              pos
	              |
	              v
	buf | a | b | c |
	              ^
	              |
	              peekLoc

	-> l.Nex() -> returns d

	                  pos
	                  |
	                  v
	buf | a | b | c | d |
	                  ^
	                  |
	                  peekLoc


	-> l.Peek() -> returns e

	                  pos
	                  |
	                  v
	buf | a | b | c | d | e |
	                      ^
	                      |
	                      peekLoc

	-> l.Backup()
	-> l.Backup()

	              pos
	              |
	              v
	buf | a | b | c | d | e |
	              ^
	              |
	              peekLoc

	-> l.Next() -> returns c

	                  pos
	                  |
	                  v
	buf | a | b | c | d | e |
	                  ^
	                  |
	                  peekLoc

	-> l.Next() -> returns d

	                      pos
	                      |
	                      v
	buf | a | b | c | d | e |
	                      ^
	                      |
	                      peekLoc
	*/
	guard := Mark("Next")
	defer func() {
		Trace("return = %q", r)
		guard()
	}()

	if l.pos == -1 || len(l.buf) == l.peekLoc+1 {
		r, _, err := l.source.ReadRune()
		switch err {
		case nil:
			l.peekLoc++
			l.pos++
			l.buf = append(l.buf, r)
		case io.EOF:
			l.peekLoc++
			l.pos++
			r = -1
			if l.buf[len(l.buf)-1] != r {
				l.buf = append(l.buf, r)
			}
		}
	} else {
		l.peekLoc++
		l.pos++
	}

	loc := l.peekLoc

	if loc < 0 || len(l.buf) <= loc {
		return EOF
		//    panic(fmt.Sprintf("FATAL: loc = %d, l.buf = %q (len = %d)", loc, l.buf, len(l.buf)))
	}

	Trace("l.buf = %q, loc = %d", l.buf, loc)
	return l.buf[loc]
}
132878
func (d *Defer) Next() *Defer {
	if d.link == nil {
		return nil
	}
	d.link.load()
	if d.link.SP < d.SP {
		d.link.Unreadable = errSPDecreased
	}
	return d.link
}