MCPcopy Create free account
hub / github.com/bytebase/bytebase / scanComment

Method scanComment

backend/plugin/parser/tokenizer/tokenizer.go:531–561  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

529}
530
531func (t *Tokenizer) scanComment() error {
532 switch {
533 case t.char(0) == '/' && t.char(1) == '*':
534 t.skip(2)
535 for {
536 switch {
537 case t.char(0) == '*' && t.char(1) == '/':
538 t.skip(2)
539 return nil
540 case t.char(0) == eofRune:
541 return errors.Errorf("invalid comment: not found */, but found EOF")
542 case t.char(0) == '\n':
543 t.line++
544 t.skip(1)
545 default:
546 t.skip(1)
547 }
548 }
549 case t.char(0) == '-' && t.char(1) == '-':
550 t.skip(2)
551 t.skipToNewLine()
552 return nil
553 case t.char(0) == '#':
554 t.skip(1)
555 t.skipToNewLine()
556 return nil
557 default:
558 // Not a comment
559 }
560 return errors.Errorf("no comment found")
561}
562
563// scanTo scans to delimiter. Use KMP algorithm.
564func (t *Tokenizer) scanTo(delimiter []rune) error {

Calls 4

charMethod · 0.95
skipMethod · 0.95
skipToNewLineMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected