func lexBlob(x *Lexer) stateFn {
	eqCount := 0
	charCount := 0

Loop:
	for {
		switch ch := x.next(); {
		case ch == eof:
			return x.error("unterminated blob")
		case ch == '}':
			if ch = x.peek(); ch != '}' {
				return x.errorf("invalid end to blob, expected } but found: %#U", ch)
			}
			// We can back up again since we know for a fact that the previous
			// character is the same width as the character we just peeked.
			x.backup()
			break Loop
		case isBlobText(ch):
			if eqCount > 0 {
				return x.error("base64 character found after padding character")
			}
			charCount++
		case ch == '=':
			eqCount++
		case isWhitespace(ch):
		default:
			return x.errorf("invalid rune as part of blob string: %#U", ch)
		}
	}

	if eqCount > 2 {
		return x.error("too much padding for base64 encoding")
	}

	if (charCount+eqCount)%4 != 0 {
		return x.error("invalid base64 encoding")
	}

	x.emit(IonBlob)
	x.next()
	x.next()
	x.emit(IonBinaryEnd)

	return lexValue
}
// lexBlob reads the base64-encoded blob, keeping all whitespace.  If the blob does
// not have the correct number of padding characters, then an error is returned.
lexBlob reads the base64-encoded blob, keeping all whitespace.  If the blob does
not have the correct number of padding characters, then an error is returned.
// lexBlob reads the base64 - encoded blob keeping all whitespace . If the blob does // not have the correct number of padding characters then an error is returned .
func lexBlob(x *Lexer) stateFn {
	eqCount := 0
	charCount := 0
Loop:
	for {
		switch ch := x.next(); {
		case ch == eof:
			return x.error("unterminated blob")
		case ch == '}':
			if ch = x.peek(); ch != '}' {
				return x.errorf("invalid end to blob, expected } but found: %#U", ch)
			}
			x.backup()
			break Loop
		case isBlobText(ch):
			if eqCount > 0 {
				return x.error("base64 character found after padding character")
			}
			charCount++
		case ch == '=':
			eqCount++
		case isWhitespace(ch):
		default:
			return x.errorf("invalid rune as part of blob string: %#U", ch)
		}
	}
	if eqCount > 2 {
		return x.error("too much padding for base64 encoding")
	}
	if (charCount+eqCount)%4 != 0 {
		return x.error("invalid base64 encoding")
	}
	x.emit(IonBlob)
	x.next()
	x.next()
	x.emit(IonBinaryEnd)
	return lexValue
}
func lexBlob ( x * Lexer ) stateFn { eqCount := 0 charCount := 0 Loop : for { switch ch := x . next ( ) ; { case ch == eof : return x . error ( " " ) case ch == '}' : if ch = x . peek ( ) ; ch != '}' { return x . errorf ( " " , ch ) } x . backup ( ) break Loop case isBlobText ( ch ) : if eqCount > 0 { return x . error ( " " ) } charCount ++ case ch == '=' : eqCount ++ case isWhitespace ( ch ) : default : return x . errorf ( " " , ch ) } } if eqCount > 2 { return x . error ( " " ) } if ( charCount + eqCount ) % 4 != 0 { return x . error ( " " ) } x . emit ( IonBlob ) x . next ( ) x . next ( ) x . emit ( IonBinaryEnd ) return lexValue }
lexBlob reads the base64-encoded blob, keeping all whitespace.
lexBlob reads the base64 - encoded blob keeping all whitespace .
// We can back up again since we know for a fact that the previous // character is the same width as the character we just peeked.