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

Method synchronize

pkg/sql/parser/recovery.go:101–114  ·  view source on GitHub ↗

synchronize advances the parser past the current error to a synchronization point: either past a semicolon or to a statement-starting keyword.

()

Source from the content-addressed store, hash-verified

99// synchronize advances the parser past the current error to a synchronization point:
100// either past a semicolon or to a statement-starting keyword.
101func (p *Parser) synchronize() {
102 for p.currentPos < len(p.tokens) && !p.isType(models.TokenTypeEOF) {
103 // If we hit a semicolon, consume it and stop
104 if p.isType(models.TokenTypeSemicolon) {
105 p.advance()
106 return
107 }
108 // If we hit a statement-starting keyword, stop (don't consume it)
109 if p.isStatementStartingKeyword() {
110 return
111 }
112 p.advance()
113 }
114}
115
116// ParseMultiWithRecovery obtains a parser from the pool and parses a token stream,
117// recovering from errors to collect multiple errors and return a partial AST.

Callers 1

parseWithRecoveryMethod · 0.95

Calls 3

isTypeMethod · 0.95
advanceMethod · 0.95

Tested by

no test coverage detected