scanBitString scans the content inside B'....'.
(lval ScanSymType, ch int)
| 883 | |
| 884 | // scanBitString scans the content inside B'....'. |
| 885 | func (s *Scanner) scanBitString(lval ScanSymType, ch int) bool { |
| 886 | s.lastAttemptedID = int32(lexbase.BITCONST) |
| 887 | buf := s.buffer() |
| 888 | outer: |
| 889 | for { |
| 890 | b := s.next() |
| 891 | switch b { |
| 892 | case ch: |
| 893 | newline, ok := s.skipWhitespace(lval, false) |
| 894 | if !ok { |
| 895 | return false |
| 896 | } |
| 897 | // SQL allows joining adjacent strings separated by whitespace |
| 898 | // as long as that whitespace contains at least one |
| 899 | // newline. Kind of strange to require the newline, but that |
| 900 | // is the standard. |
| 901 | if s.peek() == ch && newline { |
| 902 | s.pos++ |
| 903 | continue |
| 904 | } |
| 905 | break outer |
| 906 | |
| 907 | case '0', '1': |
| 908 | buf = append(buf, byte(b)) |
| 909 | default: |
| 910 | lval.SetID(lexbase.ERROR) |
| 911 | lval.SetStr(fmt.Sprintf(`"%c" is not a valid binary digit`, rune(b))) |
| 912 | return false |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | lval.SetID(lexbase.BITCONST) |
| 917 | lval.SetStr(s.finishString(buf)) |
| 918 | return true |
| 919 | } |
| 920 | |
| 921 | // scanString scans the content inside '...'. This is used for simple |
| 922 | // string literals '...' but also e'....' and b'...'. For x'...', see |
no test coverage detected