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

Method ParseWithRecovery

pkg/sql/parser/recovery.go:163–170  ·  view source on GitHub ↗

ParseWithRecovery parses a token stream, recovering from errors to collect multiple errors and return a partial AST with successfully parsed statements. WARNING: This method mutates the parser's internal state (tokens, currentPos) and is NOT safe for concurrent use on the same Parser instance. For

(tokens []token.Token)

Source from the content-addressed store, hash-verified

161// defer parser.PutParser(p)
162// stmts, errs := p.ParseWithRecovery(tokens)
163func (p *Parser) ParseWithRecovery(tokens []token.Token) ([]ast.Statement, []error) {
164 // Wrap legacy token.Token into models.TokenWithSpan for the unified path.
165 wrapped := make([]models.TokenWithSpan, len(tokens))
166 for i, t := range tokens {
167 wrapped[i] = models.WrapToken(models.Token{Type: t.Type, Value: t.Literal})
168 }
169 return p.parseWithRecovery(preprocessTokens(wrapped))
170}
171
172// ParseWithRecoveryFromModelTokens parses tokenizer output with error recovery.
173func (p *Parser) ParseWithRecoveryFromModelTokens(tokens []models.TokenWithSpan) ([]ast.Statement, []error) {

Callers 1

Calls 3

parseWithRecoveryMethod · 0.95
WrapTokenFunction · 0.92
preprocessTokensFunction · 0.85

Tested by 1