Scan scans the next token and populates its information into lval.
(lval ScanSymType)
| 167 | |
| 168 | // Scan scans the next token and populates its information into lval. |
| 169 | func (s *SQLScanner) Scan(lval ScanSymType) { |
| 170 | ch, skipWhiteSpace := s.scanSetup(lval, true /* allowComments */) |
| 171 | |
| 172 | if skipWhiteSpace { |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | switch ch { |
| 177 | case '$': |
| 178 | // placeholder? $[0-9]+ |
| 179 | if lexbase.IsDigit(s.peek()) { |
| 180 | s.scanPlaceholder(lval) |
| 181 | return |
| 182 | } else if s.scanDollarQuotedString(lval) { |
| 183 | lval.SetID(lexbase.SCONST) |
| 184 | return |
| 185 | } |
| 186 | return |
| 187 | |
| 188 | case identQuote: |
| 189 | // "[^"]" |
| 190 | s.lastAttemptedID = int32(lexbase.IDENT) |
| 191 | s.quoted = true |
| 192 | if s.scanString(lval, identQuote, false /* allowEscapes */, true /* requireUTF8 */) { |
| 193 | lval.SetID(lexbase.IDENT) |
| 194 | } |
| 195 | return |
| 196 | |
| 197 | case singleQuote: |
| 198 | // '[^']' |
| 199 | s.lastAttemptedID = int32(lexbase.SCONST) |
| 200 | if s.scanString(lval, ch, false /* allowEscapes */, true /* requireUTF8 */) { |
| 201 | lval.SetID(lexbase.SCONST) |
| 202 | } |
| 203 | return |
| 204 | |
| 205 | case 'b': |
| 206 | // Bytes? |
| 207 | if s.peek() == singleQuote { |
| 208 | // b'[^']' |
| 209 | s.lastAttemptedID = int32(lexbase.BCONST) |
| 210 | s.pos++ |
| 211 | if s.scanString(lval, singleQuote, true /* allowEscapes */, false /* requireUTF8 */) { |
| 212 | lval.SetID(lexbase.BCONST) |
| 213 | } |
| 214 | return |
| 215 | } |
| 216 | s.scanIdent(lval) |
| 217 | return |
| 218 | |
| 219 | case 'r', 'R': |
| 220 | s.scanIdent(lval) |
| 221 | return |
| 222 | |
| 223 | case 'e', 'E': |
| 224 | // Escaped string? |
| 225 | if s.peek() == singleQuote { |
| 226 | // [eE]'[^']' |
no test coverage detected