MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / scanIdent

Method scanIdent

pkg/sql/scanner/scan.go:664–697  ·  view source on GitHub ↗
(lval ScanSymType)

Source from the content-addressed store, hash-verified

662}
663
664func (s *Scanner) scanIdent(lval ScanSymType) {
665 s.normalizeIdent(lval, lexbase.IsIdentMiddle, true /* toLower */)
666
667 isExperimental := false
668 kw := lval.Str()
669 switch {
670 case strings.HasPrefix(lval.Str(), "experimental_"):
671 kw = lval.Str()[13:]
672 isExperimental = true
673 case strings.HasPrefix(lval.Str(), "testing_"):
674 kw = lval.Str()[8:]
675 isExperimental = true
676 }
677 lval.SetID(lexbase.GetKeywordID(kw))
678 if lval.ID() != lexbase.IDENT {
679 if isExperimental {
680 if _, ok := lexbase.AllowedExperimental[kw]; !ok {
681 // If the parsed token is not on the allowlisted set of keywords,
682 // then it might have been intended to be parsed as something else.
683 // In that case, re-tokenize the original string.
684 lval.SetID(lexbase.GetKeywordID(lval.Str()))
685 } else {
686 // It is a allowlisted keyword, so remember the shortened
687 // keyword for further processing.
688 lval.SetStr(kw)
689 }
690 }
691 } else {
692 // If the word after experimental_ or testing_ is an identifier,
693 // then we might have classified it incorrectly after removing the
694 // experimental_/testing_ prefix.
695 lval.SetID(lexbase.GetKeywordID(lval.Str()))
696 }
697}
698
699func (s *Scanner) scanNumber(lval ScanSymType, ch int) {
700 s.scanNumberImpl(lval, ch, lexbase.ERROR, lexbase.FCONST, lexbase.ICONST)

Callers 1

ScanMethod · 0.45

Calls 6

normalizeIdentMethod · 0.95
GetKeywordIDFunction · 0.92
StrMethod · 0.65
SetIDMethod · 0.65
IDMethod · 0.65
SetStrMethod · 0.65

Tested by

no test coverage detected