MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / scanComment

Method scanComment

pkg/sql/parser/scan.go:440–495  ·  view source on GitHub ↗
(lval *sqlSymType)

Source from the content-addressed store, hash-verified

438}
439
440func (s *scanner) scanComment(lval *sqlSymType) (present, ok bool) {
441 start := s.pos
442 ch := s.peek()
443
444 if ch == '/' {
445 s.pos++
446 if s.peek() != '*' {
447 s.pos--
448 return false, true
449 }
450 s.pos++
451 depth := 1
452 for {
453 switch s.next() {
454 case '*':
455 if s.peek() == '/' {
456 s.pos++
457 depth--
458 if depth == 0 {
459 return true, true
460 }
461 continue
462 }
463
464 case '/':
465 if s.peek() == '*' {
466 s.pos++
467 depth++
468 continue
469 }
470
471 case eof:
472 lval.id = ERROR
473 lval.pos = int32(start)
474 lval.str = "unterminated comment"
475 return false, false
476 }
477 }
478 }
479
480 if ch == '-' {
481 s.pos++
482 if s.peek() != '-' {
483 s.pos--
484 return false, true
485 }
486 for {
487 switch s.next() {
488 case eof, '\n':
489 return true, true
490 }
491 }
492 }
493
494 return false, true
495}
496
497func (s *scanner) scanIdent(lval *sqlSymType) {

Callers 1

skipWhitespaceMethod · 0.95

Calls 2

peekMethod · 0.95
nextMethod · 0.95

Tested by

no test coverage detected