scanBitString scans the content inside B'....'.
(lval *sqlSymType, ch int)
| 750 | |
| 751 | // scanBitString scans the content inside B'....'. |
| 752 | func (s *scanner) scanBitString(lval *sqlSymType, ch int) bool { |
| 753 | buf := s.buffer() |
| 754 | outer: |
| 755 | for { |
| 756 | b := s.next() |
| 757 | switch b { |
| 758 | case ch: |
| 759 | newline, ok := s.skipWhitespace(lval, false) |
| 760 | if !ok { |
| 761 | return false |
| 762 | } |
| 763 | // SQL allows joining adjacent strings separated by whitespace |
| 764 | // as long as that whitespace contains at least one |
| 765 | // newline. Kind of strange to require the newline, but that |
| 766 | // is the standard. |
| 767 | if s.peek() == ch && newline { |
| 768 | s.pos++ |
| 769 | continue |
| 770 | } |
| 771 | break outer |
| 772 | |
| 773 | case '0', '1': |
| 774 | buf = append(buf, byte(b)) |
| 775 | default: |
| 776 | lval.id = ERROR |
| 777 | lval.str = fmt.Sprintf(`"%c" is not a valid binary digit`, rune(b)) |
| 778 | return false |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | lval.id = BITCONST |
| 783 | lval.str = s.finishString(buf) |
| 784 | return true |
| 785 | } |
| 786 | |
| 787 | // scanString scans the content inside '...'. This is used for simple |
| 788 | // string literals '...' but also e'....' and b'...'. For x'...', see |
no test coverage detected