MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / GetTokenType

Method GetTokenType

pkg/sql/keywords/keywords.go:333–345  ·  view source on GitHub ↗

GetTokenType returns the token type for a given keyword. If the word is not a recognized keyword, it returns models.TokenTypeWord. The lookup is case-insensitive when the Keywords instance was created with case-insensitive matching (default behavior). Example: kw := keywords.New(keywords.Dialect

(word string)

Source from the content-addressed store, hash-verified

331// tokenType = kw.GetTokenType("select") // models.TokenTypeSelect (case-insensitive)
332// tokenType = kw.GetTokenType("unknown") // models.TokenTypeWord
333func (k *Keywords) GetTokenType(word string) models.TokenType {
334 var key string
335 if k.ignoreCase {
336 key = strings.ToUpper(word)
337 } else {
338 key = word
339 }
340
341 if kw, ok := k.keywordMap[key]; ok {
342 return kw.Type
343 }
344 return models.TokenTypeWord
345}

Calls

no outgoing calls