New creates a new Tokenizer with default configuration and keyword support. The returned tokenizer is ready to use for tokenizing SQL statements. For production use, prefer GetTokenizer() which uses object pooling for better performance and reduced allocations. Returns an error only if keyword ini
()
| 292 | // } |
| 293 | // tokens, err := tkz.Tokenize([]byte("SELECT * FROM users")) |
| 294 | func New() (*Tokenizer, error) { |
| 295 | kw := keywords.NewKeywords() |
| 296 | return &Tokenizer{ |
| 297 | keywords: kw, |
| 298 | dialect: keywords.DialectPostgreSQL, |
| 299 | pos: NewPosition(1, 0), |
| 300 | lineStarts: []int{0}, |
| 301 | }, nil |
| 302 | } |
| 303 | |
| 304 | // NewWithDialect creates a new Tokenizer configured for the given SQL dialect. |
| 305 | // Dialect-specific keywords are recognized based on the dialect parameter. |