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)
| 349 | // return err |
| 350 | // } |
| 351 | func 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 | // |