// Scan hex digits until we hit a closing brace.
// Non-hex digits, hex value too large for UTF-8, or running out of chars are errors
425997
func (p *parser) scanHexUntilBrace() (rune, error) {
	// PCRE spec reads like unlimited hex digits are allowed, but unicode has a limit
	// so we can enforce that
	i := 0
	hasContent := false

	for p.charsRight() > 0 {
		ch := p.moveRightGetChar()
		if ch == '}' {
			// hit our close brace, we're done here
			// prevent \x{}
			if !hasContent {
				return 0, p.getErr(ErrTooFewHex)
			}
			return rune(i), nil
		}
		hasContent = true
		// no brace needs to be hex digit
		d := hexDigit(ch)
		if d < 0 {
			return 0, p.getErr(ErrMissingBrace)
		}

		i *= 0x10
		i += d

		if i > unicode.MaxRune {
			return 0, p.getErr(ErrInvalidHex)
		}
	}

	// we only make it here if we run out of digits without finding the brace
	return 0, p.getErr(ErrMissingBrace)
}
118104
func (f *Float64) Scan(value interface{}) (err error) {
	if value == nil {
		f.Float64, f.Valid = 0.0, false
		return nil
	}
	f.Valid = true

	switch v := value.(type) {
	case []byte:
		f.Float64, err = strconv.ParseFloat(string(v), 64)
	case string:
		f.Float64, err = strconv.ParseFloat(v, 64)
	case float64:
		f.Float64 = v
	default:
		err = fmt.Errorf("ntypes: unsuported type (%T) passed to Float64.Scan", value)
	}

	return
}
736198
func (s *Scanner) Scan() (Token, bool) {
	var tok Token

	if !s.eof && s.cur == -1 {
		// move to first rune
		s.read()
	}

	s.skipWhitespace()
	tok.pos = s.cpos

	// the first switch cases all position the scanner on the next rune
	// by their calls to scan*
	switch {
	case s.eof:
		tok.id = eof
	case isLetter(s.cur):
		tok.id = ident
		tok.lit = s.scanIdentifier()
		if _, ok := blacklistedIdents[tok.lit]; ok {
			s.errorpf(tok.pos, "illegal identifier %q", tok.lit)
		}
	case isRuleDefStart(s.cur):
		tok.id = ruledef
		tok.lit = s.scanRuleDef()
	case s.cur == '\'':
		tok.id = char
		tok.lit = s.scanChar()
	case s.cur == '"':
		tok.id = str
		tok.lit = s.scanString()
	case s.cur == '`':
		tok.id = rstr
		tok.lit = s.scanRawString()
	case s.cur == '[':
		tok.id = class
		tok.lit = s.scanClass()
	case s.cur == '{':
		tok.id = code
		tok.lit = s.scanCode()

	default:
		r := s.cur
		s.read()
		switch r {
		case '/':
			if s.cur == '*' || s.cur == '/' {
				tok.id, tok.lit = s.scanComment()
				break
			}
			fallthrough
		case ':', ';', '(', ')', '.', '&', '!', '?', '+', '*', '\n':
			tok.id = tid(r)
			tok.lit = string(r)
		default:
			s.errorf("invalid character %#U", r)
			tok.id = invalid
			tok.lit = string(r)
		}
	}

	return tok, tok.id != eof
}
217978
func (kf *KeyFormat) Scan(key []byte, args ...interface{}) error {
	segments := kf.ScanBytes(key)
	if len(args) > len(segments) {
		return fmt.Errorf("KeyFormat.Scan() is provided with %d args but format only has %d segments in key %X",
			len(args), len(segments), key)
	}
	for i, a := range args {
		scan(a, segments[i])
	}
	return nil
}
897238
func (c *CSPRNG) HexDigest(bytes int) (string, error) {
	return hexDigest(c, bytes)
}
221688
func (u *Uint32) Scan(value interface{}) (err error) {
	if value == nil {
		u.Uint32, u.Valid = 0, false
		return nil
	}
	u.Valid = true

	var tmp uint64
	switch v := value.(type) {
	case []byte:
		tmp, err = strconv.ParseUint(string(v), 10, 32)
		if err != nil {
			return fmt.Errorf("ntypes: Uint32.Scan failure: %s", err)
		}
		u.Uint32 = uint32(tmp)
	case string:
		tmp, err = strconv.ParseUint(v, 10, 32)
		if err != nil {
			return fmt.Errorf("ntypes: Uint32.Scan failure: %s", err)
		}
		u.Uint32 = uint32(tmp)
	case int64:
		if v > math.MaxUint32 {
			return errors.New("ntypes: Uint32.Scan failure: value out of range")
		}
		u.Uint32 = uint32(v)
	default:
		err = fmt.Errorf("ntypes: unsuported type (%T) passed to Uint32.Scan", value)
	}

	return
}
263788
func (n *NetID) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return errors.New("lorawan: []byte type expected")
	}
	if len(b) != len(n) {
		return fmt.Errorf("lorawan: []byte must have length %d", len(n))
	}
	copy(n[:], b)
	return nil
}
399358
func (u *UUID) Scan(src interface{}) error {
	switch src := src.(type) {
	case []byte:
		if len(src) == uuid.Size {
			return u.UnmarshalBinary(src)
		}
		return u.UnmarshalText(src)

	case string:
		return u.UnmarshalText([]byte(src))
	}

	return fmt.Errorf("uuid: cannot convert %T to UUID", src)
}
739527
func (id *ID) Scan(value interface{}) (err error) {
	switch val := value.(type) {
	case string:
		return id.UnmarshalText([]byte(val))
	case []byte:
		return id.UnmarshalText(val)
	case nil:
		*id = nilID
		return nil
	default:
		return fmt.Errorf("xid: scanning unsupported type: %T", value)
	}
}
886216
func (o *UUID) Scan(src interface{}) error {
	if src == nil {
		return nil
	}
	if src == "" {
		return nil
	}
	switch src := src.(type) {

	case string:
		return o.UnmarshalText([]byte(src))

	case []byte:
		if len(src) == length {
			return o.UnmarshalBinary(src)
		} else {
			return o.UnmarshalText(src)
		}

	default:
		return fmt.Errorf("uuid: cannot scan type [%T] into UUID", src)
	}
}
358578
func (self *_parser) Scan() (tkn token.Token, literal string, idx file.Idx) {
	return self.scan()
}
654534
func (s *Scanner) Scan() (r rune) {
	s.tokenIdx = 0
	r, _, err := s.r.ReadRune()
	prevRune := r

	if s.Whitespace.Get(int(r)) {
		s.token[s.tokenIdx] = r
		s.tokenIdx++
		return r
	}

	for ; !s.Whitespace.Get(int(r)); r, _, err = s.r.ReadRune() {
		switch err {
		case nil:
			break
		case io.EOF:
			return EOF
		default:
			s.Error(err)
			return EOF
		}
		s.token[s.tokenIdx] = r
		s.tokenIdx++
		prevRune = r
	}

	// We have to UnreadRune because we went too far of one rune
	err = s.r.UnreadRune()
	if err != nil {
		s.Error(err)
	}

	return prevRune
}
130529
func (n *NullFloat32) Scan(value interface{}) (err error) {
	if value == nil {
		n.Float32, n.Valid = 0, false
		return
	}

	switch v := value.(type) {
	case float64:
		n.Float32, n.Valid = float32(v), true
		return
	case []uint8:
		if i, e := strconv.ParseFloat(string(v), 10); e == nil {
			n.Float32, n.Valid = float32(i), true
		}
		return
	}

	n.Valid = false
	return fmt.Errorf("null: can't convert %T to float32", value)
}
1276584
func (s *scanner) scan() (token, string, error) {
	ch, _, err := s.r.ReadRune()

	if err != nil && err != io.EOF {
		return tokenError, "", err
	}

	switch ch {
	case zeroRune:
		return eof, "", nil
	case ':':
		return colon, string(ch), nil
	case '~':
		return tilde, string(ch), nil
	case '^':
		return caret, string(ch), nil
	case '.':
		return dot, string(ch), nil
	case '/':
		return slash, string(ch), nil
	case '{':
		return obrace, string(ch), nil
	case '}':
		return cbrace, string(ch), nil
	case '-':
		return minus, string(ch), nil
	case '@':
		return at, string(ch), nil
	case '\\':
		return aslash, string(ch), nil
	case '?':
		return qmark, string(ch), nil
	case '*':
		return asterisk, string(ch), nil
	case '[':
		return obracket, string(ch), nil
	case '!':
		return emark, string(ch), nil
	}

	if unicode.IsSpace(ch) {
		return space, string(ch), nil
	}

	if unicode.IsControl(ch) {
		return control, string(ch), nil
	}

	if unicode.IsLetter(ch) {
		return tokenizeExpression(ch, word, unicode.IsLetter, s.r)
	}

	if unicode.IsNumber(ch) {
		return tokenizeExpression(ch, number, unicode.IsNumber, s.r)
	}

	return tokenError, string(ch), nil
}
494972
func (f *FakeRNG) HexDigest(bytes int) (string, error) {
	return hexDigest(f, bytes)
}
944892
func (s *Scanner) Scan() (tok Token, pos Pos, lit string) {

	// Read next code point.
	ch0, pos := s.r.read()

	// If we see whitespace then consume all contiguous whitespace.
	// If we see a letter, or certain acceptable special characters, then consume
	// as an ident or reserved word.
	if isWhitespace(ch0) {
		return s.scanWhitespace()
	} else if isLetter(ch0) || ch0 == '_' {
		s.r.unread()
		return s.scanIdent()
	} else if isDigit(ch0) {
		return s.scanNumber()
	}

	// Otherwise parse individual characters.
	switch ch0 {
	case eof:
		return EOF, pos, ""
	case '"':
		return s.scanString()
	case '\'':
		return s.scanString()
	case '.':
		ch1, _ := s.r.read()
		s.r.unread()
		if isDigit(ch1) {
			return s.scanNumber()
		}
		return DOT, pos, ""
	case '+':
		if ch1, _ := s.r.read(); ch1 == '+' {
			return PLUSPLUS, pos, ""
		}
		s.r.unread()
		return PLUS, pos, "+"
		// return s.scanNumber()
	case '-':
		if ch1, _ := s.r.read(); ch1 == '>' {
			return ARROW, pos, ""
		} else if ch1 == '-' {
			return MINUSMINUS, pos, ""
		}
		s.r.unread()
		return MINUS, pos, "-"
		// return s.scanNumber()
	case '*':
		if ch1, _ := s.r.read(); ch1 == '*' {
			return POW, pos, ""
		}
		s.r.unread()
		return MUL, pos, ""
	case '/':
		return DIV, pos, ""
	case '=':
		if ch1, _ := s.r.read(); ch1 == '~' {
			return EQREGEX, pos, ""
		} else if ch1 == '>' {
			return EQARROW, pos, ""
		} else if ch1 == '=' {
			return EQEQ, pos, ""
		}
		s.r.unread()
		return EQ, pos, ""
	case '!':
		if ch1, _ := s.r.read(); ch1 == '=' {
			return NEQ, pos, ""
		} else if ch1 == '~' {
			return NEQREGEX, pos, ""
		}
		s.r.unread()
	case '>':
		if ch1, _ := s.r.read(); ch1 == '=' {
			return GTE, pos, ""
		} else if ch1 == '>' {
			return RSHIFT, pos, ""
		}
		s.r.unread()
		return GT, pos, ""
	case '<':
		if ch1, _ := s.r.read(); ch1 == '=' {
			return LTE, pos, ""
		} else if ch1 == '>' {
			return NEQ, pos, ""
		} else if ch1 == '<' {
			return LSHIFT, pos, ""
		}
		s.r.unread()
		return LT, pos, ""
	case '(':
		return LPAREN, pos, ""
	case ')':
		return RPAREN, pos, ""
	case '[':
		return LBRACKET, pos, ""
	case ']':
		return RBRACKET, pos, ""
	case '{':
		return LCURLY, pos, ""
	case '}':
		return RCURLY, pos, ""
	case ',':
		return COMMA, pos, ""
	case ';':
		return SEMICOLON, pos, ""
	case ':':
		return COLON, pos, ""
	case '^':
		return XOR, pos, ""
	case '|':
		return PIPE, pos, ""
	case '&':
		return AMPERSAND, pos, ""
	case '%':
		return PERCENT, pos, ``
	case '$':
		return DOLLAR, pos, ""
	case '#':
		return HASH, pos, ""
	case '@':
		return ATSIGN, pos, ""
	}

	return ILLEGAL, pos, string(ch0)
}
473934
func (l *lexer) scan() *token {
	for {
		r, eof := l.next()
		if eof {
			return &token{tEOF, tEOF, ""}
		} else if isWhitespace(r) || l.eof() { // we just scanned some meaningful data
			token := l.scanIdent()
			l.scanWhitespaces()
			l.moveon()
			return token
		}
	}
}