There are two ways to include a single quote('), using \' or two single-quotes. We only handle the case \', because the second case does not require special handling. And this is extensible. For MySQL, user can enclose string within double quote(").
(delimiter rune)
| 504 | // And this is extensible. |
| 505 | // For MySQL, user can enclose string within double quote("). |
| 506 | func (t *Tokenizer) scanString(delimiter rune) error { |
| 507 | if t.char(0) != delimiter { |
| 508 | return errors.Errorf("string doesn't start with delimiter: %c, but found: %c", delimiter, t.char(0)) |
| 509 | } |
| 510 | |
| 511 | t.skip(1) |
| 512 | for { |
| 513 | switch t.char(0) { |
| 514 | case delimiter: |
| 515 | t.skip(1) |
| 516 | return nil |
| 517 | case eofRune: |
| 518 | return errors.Errorf("invalid string: not found delimiter: %c, but found EOF", delimiter) |
| 519 | case '\\': |
| 520 | // skip two because we want to skip \' and \\. |
| 521 | t.skip(2) |
| 522 | case '\n': |
| 523 | t.line++ |
| 524 | t.skip(1) |
| 525 | default: |
| 526 | t.skip(1) |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | func (t *Tokenizer) scanComment() error { |
| 532 | switch { |
no test coverage detected