Example demonstrates basic keyword detection and token type identification.
()
| 23 | |
| 24 | // Example demonstrates basic keyword detection and token type identification. |
| 25 | func Example() { |
| 26 | // Create a keywords instance for generic SQL dialect |
| 27 | kw := keywords.New(keywords.DialectGeneric, true) |
| 28 | |
| 29 | // Check if a word is a SQL keyword |
| 30 | if kw.IsKeyword("SELECT") { |
| 31 | fmt.Println("SELECT is a keyword") |
| 32 | } |
| 33 | |
| 34 | // Get the token type for a keyword |
| 35 | tokenType := kw.GetTokenType("WHERE") |
| 36 | fmt.Printf("WHERE token type: %v\n", tokenType) |
| 37 | |
| 38 | // Check if a keyword is reserved |
| 39 | if kw.IsReserved("FROM") { |
| 40 | fmt.Println("FROM is a reserved keyword") |
| 41 | } |
| 42 | |
| 43 | // Output: |
| 44 | // SELECT is a keyword |
| 45 | // WHERE token type: WHERE |
| 46 | // FROM is a reserved keyword |
| 47 | } |
| 48 | |
| 49 | // Example_dialectSupport demonstrates SQL dialect-specific keyword recognition. |
| 50 | func Example_dialectSupport() { |
nothing calls this directly
no test coverage detected