MCPcopy Index your code
hub / github.com/bytebase/bytebase / scanString

Method scanString

backend/plugin/parser/tokenizer/tokenizer.go:506–529  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

504// And this is extensible.
505// For MySQL, user can enclose string within double quote(").
506func (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
531func (t *Tokenizer) scanComment() error {
532 switch {

Calls 3

charMethod · 0.95
skipMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected