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

Function NewWithKeywords

pkg/sql/tokenizer/tokenizer.go:351–361  ·  view source on GitHub ↗

NewWithKeywords initializes a Tokenizer with a custom keyword classifier. This allows you to customize keyword recognition for specific SQL dialects or to add custom keywords. The keywords parameter must not be nil. Returns an error if keywords is nil. Example: kw := keywords.NewKeywords() //

(kw *keywords.Keywords)

Source from the content-addressed store, hash-verified

349// return err
350// }
351func NewWithKeywords(kw *keywords.Keywords) (*Tokenizer, error) {
352 if kw == nil {
353 return nil, errors.InvalidSyntaxError("keywords cannot be nil", models.Location{Line: 1, Column: 0}, "")
354 }
355
356 return &Tokenizer{
357 keywords: kw,
358 pos: NewPosition(1, 0),
359 lineStarts: []int{0},
360 }, nil
361}
362
363// Tokenize converts raw SQL bytes into a slice of tokens with position information.
364//

Callers 2

TestNewWithKeywordsFunction · 0.85

Calls 2

InvalidSyntaxErrorFunction · 0.92
NewPositionFunction · 0.85

Tested by 2

TestNewWithKeywordsFunction · 0.68