MCPcopy Create free account
hub / github.com/dolthub/doltgresql / skipWhitespace

Method skipWhitespace

postgres/parser/parser/scan.go:452–479  ·  view source on GitHub ↗

skipWhitespace skips over whitespace characters (space, tab, newline, etc) and comments. Multiple consecutive block comments and whitespace will be concatenated together into the final return value.

(lval *sqlSymType, allowComments bool)

Source from the content-addressed store, hash-verified

450// skipWhitespace skips over whitespace characters (space, tab, newline, etc) and comments. Multiple consecutive
451// block comments and whitespace will be concatenated together into the final return value.
452func (s *scanner) skipWhitespace(lval *sqlSymType, allowComments bool) (blockComment string, newline, ok bool) {
453 newline = false
454 for {
455 ch := s.peek()
456 if ch == '\n' {
457 s.pos++
458 newline = true
459 continue
460 }
461 if ch == ' ' || ch == '\t' || ch == '\r' || ch == '\f' {
462 s.pos++
463 continue
464 }
465 if allowComments {
466 if cmt, present, cok := s.scanComment(lval); !cok {
467 return "", false, false
468 } else if present {
469 if len(blockComment) > 0 {
470 blockComment += " "
471 }
472 blockComment += cmt
473 continue
474 }
475 }
476 break
477 }
478 return blockComment, newline, true
479}
480
481// scanComment scans for a comment starting at the current position.
482// For block-style comments, returns the comment string scanned.

Callers 4

scanMethod · 0.95
scanHexStringMethod · 0.95
scanBitStringMethod · 0.95
scanStringMethod · 0.95

Calls 2

peekMethod · 0.95
scanCommentMethod · 0.95

Tested by

no test coverage detected