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

Function Tokens

pkg/sql/parser/scanner.go:38–52  ·  view source on GitHub ↗

Tokens decomposes the input into lexical tokens.

(sql string)

Source from the content-addressed store, hash-verified

36
37// Tokens decomposes the input into lexical tokens.
38func Tokens(sql string) (tokens []TokenString, ok bool) {
39 s := makeSQLScanner(sql)
40 for {
41 var lval = &sqlSymType{}
42 s.Scan(lval)
43 if lval.ID() == lexbase.ERROR {
44 return nil, false
45 }
46 if lval.ID() == 0 {
47 break
48 }
49 tokens = append(tokens, TokenString{TokenID: lval.ID(), Str: lval.Str()})
50 }
51 return tokens, true
52}
53
54// TokenString is the unit value returned by Tokens.
55type TokenString struct {

Callers

nothing calls this directly

Calls 4

makeSQLScannerFunction · 0.85
IDMethod · 0.65
StrMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…