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

Function Example

pkg/sql/keywords/example_test.go:25–47  ·  view source on GitHub ↗

Example demonstrates basic keyword detection and token type identification.

()

Source from the content-addressed store, hash-verified

23
24// Example demonstrates basic keyword detection and token type identification.
25func 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.
50func Example_dialectSupport() {

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
GetTokenTypeMethod · 0.80
IsReservedMethod · 0.80
IsKeywordMethod · 0.45

Tested by

no test coverage detected