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

Function parseWithPositions

pkg/sql/ast/positions_test.go:33–52  ·  view source on GitHub ↗

parseWithPositions is a test helper that tokenizes and parses SQL with full position tracking enabled, returning the AST ready for inspection.

(t *testing.T, sql string)

Source from the content-addressed store, hash-verified

31// parseWithPositions is a test helper that tokenizes and parses SQL with
32// full position tracking enabled, returning the AST ready for inspection.
33func parseWithPositions(t *testing.T, sql string) *ast.AST {
34 t.Helper()
35
36 tkz := tokenizer.GetTokenizer()
37 defer tokenizer.PutTokenizer(tkz)
38
39 tokens, err := tkz.Tokenize([]byte(sql))
40 if err != nil {
41 t.Fatalf("tokenize failed: %v", err)
42 }
43
44 p := parser.GetParser()
45 defer parser.PutParser(p)
46
47 result, err := p.ParseFromModelTokens(tokens)
48 if err != nil {
49 t.Fatalf("parse failed: %v", err)
50 }
51 return result
52}
53
54// assertPos checks that a Location is non-zero (has been populated).
55func assertPos(t *testing.T, label string, loc models.Location) {

Calls 8

GetTokenizerFunction · 0.92
PutTokenizerFunction · 0.92
GetParserFunction · 0.92
PutParserFunction · 0.92
TokenizeMethod · 0.80
ParseFromModelTokensMethod · 0.80
HelperMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected