internal/scanner/scanner.go
func (s *Scanner) Next() rune {

	s.b.Reset()

	ch := s.next()

	for unicode.IsSpace(ch) {
		ch = s.next()
	}

	tok := ch

	switch {

	default:
		tok = Undefined
		ch = s.next()

	case ch == EOF:
		break

	case isOperator(ch):
		tok = Operator
		ch = s.scanOperator(ch)

	case isDelimiter(ch):
		tok = Delimiter
		s.b.WriteRune(ch)
		ch = s.next()

	case isNameDelimiter(ch):
		tok = IdentifierDelimiter
		s.b.WriteRune(ch)
		ch = s.next()

	case isIdentifier(ch):
		tok = Identifier
		s.b.WriteRune(ch)
		ch = s.scanAlpha()

	case isSingleQuote(ch):
		tok = String
		ch = s.scanQuotedIdentifier(ch)

	case isDoubleQuote(ch):
		tok = QuotedIdentifier
		ch = s.scanQuotedIdentifier(ch)

	case isQuestionMark(ch):
		tok = Variable
		ch = s.next()

	case isColon(ch):
		ch = s.peek()
		if isDigit(ch) {
			tok = PosVariable
			ch = s.scanNumeric()
		} else {
			tok = NamedVariable
			ch = s.scanAlpha()
		}

	case isNumber(ch):
		tok = Number
		ch = s.scanNumber()
	}

	s.ch = ch
	s.rd.UnreadRune()

	if ch == Error {
		return ch
	}

	return tok
}
func (s *Scanner) Next() rune {

	s.b.Reset()

	ch := s.next()

	for unicode.IsSpace(ch) {
		ch = s.next()
	}

	tok := ch

	switch {

	default:
		tok = Undefined
		ch = s.next()

	case ch == EOF:
		break

	case isOperator(ch):
		tok = Operator
		ch = s.scanOperator(ch)

	case isDelimiter(ch):
		tok = Delimiter
		s.b.WriteRune(ch)
		ch = s.next()

	case isNameDelimiter(ch):
		tok = IdentifierDelimiter
		s.b.WriteRune(ch)
		ch = s.next()

	case isIdentifier(ch):
		tok = Identifier
		s.b.WriteRune(ch)
		ch = s.scanAlpha()

	case isSingleQuote(ch):
		tok = String
		ch = s.scanQuotedIdentifier(ch)

	case isDoubleQuote(ch):
		tok = QuotedIdentifier
		ch = s.scanQuotedIdentifier(ch)

	case isQuestionMark(ch):
		tok = Variable
		ch = s.next()

	case isColon(ch):
		ch = s.peek()
		if isDigit(ch) {
			tok = PosVariable
			ch = s.scanNumeric()
		} else {
			tok = NamedVariable
			ch = s.scanAlpha()
		}

	case isNumber(ch):
		tok = Number
		ch = s.scanNumber()
	}

	s.ch = ch
	s.rd.UnreadRune()

	if ch == Error {
		return ch
	}

	return tok
}
// Next returns the next Token.