scanBitString scans the content inside B'....'.
(lval *sqlSymType, ch int)
| 806 | |
| 807 | // scanBitString scans the content inside B'....'. |
| 808 | func (s *scanner) scanBitString(lval *sqlSymType, ch int) bool { |
| 809 | buf := s.buffer() |
| 810 | outer: |
| 811 | for { |
| 812 | b := s.next() |
| 813 | switch b { |
| 814 | case ch: |
| 815 | _, newline, ok := s.skipWhitespace(lval, false) |
| 816 | if !ok { |
| 817 | return false |
| 818 | } |
| 819 | // SQL allows joining adjacent strings separated by whitespace |
| 820 | // as long as that whitespace contains at least one |
| 821 | // newline. Kind of strange to require the newline, but that |
| 822 | // is the standard. |
| 823 | if s.peek() == ch && newline { |
| 824 | s.pos++ |
| 825 | continue |
| 826 | } |
| 827 | break outer |
| 828 | |
| 829 | case '0', '1': |
| 830 | buf = append(buf, byte(b)) |
| 831 | default: |
| 832 | lval.id = ERROR |
| 833 | lval.str = fmt.Sprintf(`"%c" is not a valid binary digit`, rune(b)) |
| 834 | return false |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | lval.id = BITCONST |
| 839 | lval.str = s.finishString(buf) |
| 840 | return true |
| 841 | } |
| 842 | |
| 843 | // scanString scans the content inside '...'. This is used for simple |
| 844 | // string literals '...' but also e'....' and b'...'. For x'...', see |
no test coverage detected