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

Method Parse

pkg/sql/parser/parser.go:253–262  ·  view source on GitHub ↗

Deprecated: Parse is provided for backward compatibility only. Use ParseFromModelTokens with a []models.TokenWithSpan slice from the tokenizer instead. This shim wraps each token.Token into a zero-span models.TokenWithSpan and has no position information. Parse parses a slice of token.Token into an

(tokens []token.Token)

Source from the content-addressed store, hash-verified

251//
252// Thread Safety: NOT thread-safe - use separate parser instances per goroutine.
253func (p *Parser) Parse(tokens []token.Token) (*ast.AST, error) {
254 // Wrap legacy token.Token into models.TokenWithSpan (spans are zero).
255 wrapped := make([]models.TokenWithSpan, len(tokens))
256 for i, t := range tokens {
257 wrapped[i] = models.WrapToken(models.Token{Type: t.Type, Value: t.Literal})
258 }
259 // Preprocessing still normalises compound tokens and keyword types.
260 preprocessed := preprocessTokens(wrapped)
261 return p.parseTokens(preprocessed)
262}
263
264// parseTokens is the core parsing routine. It takes a preprocessed
265// []models.TokenWithSpan (already normalised by preprocessTokens) and returns

Calls 3

parseTokensMethod · 0.95
WrapTokenFunction · 0.92
preprocessTokensFunction · 0.85