MCPcopy Create free account
hub / github.com/dolthub/doltgresql / parseWithDepth

Method parseWithDepth

postgres/parser/parser/parse.go:174–200  ·  view source on GitHub ↗
(depth int, sql string, nakedIntType *types.T)

Source from the content-addressed store, hash-verified

172}
173
174func (p *Parser) parseWithDepth(depth int, sql string, nakedIntType *types.T) (Statements, error) {
175 stmts := Statements(p.stmtBuf[:0])
176 p.scanner.init(sql)
177 defer p.scanner.cleanup()
178 var err error
179 for {
180 done := p.scanOneStmt(func(sqlStr string, tokens []sqlSymType) error {
181 var stmt Statement
182 stmt, err = p.parse(depth+1, sqlStr, tokens, nakedIntType)
183 if err != nil {
184 // if it's EOF syntax error, try running again
185 return err
186 }
187 if stmt.AST != nil {
188 stmts = append(stmts, stmt)
189 }
190 return nil
191 })
192 if done {
193 break
194 }
195 }
196 if err != nil {
197 return nil, err
198 }
199 return stmts, nil
200}
201
202// parse parses a statement from the given scanned tokens.
203func (p *Parser) parse(

Callers 4

ParseMethod · 0.95
ParseWithIntMethod · 0.95
parseOneWithDepthMethod · 0.95
ParseFunction · 0.95

Calls 5

scanOneStmtMethod · 0.95
parseMethod · 0.95
StatementsTypeAlias · 0.85
initMethod · 0.45
cleanupMethod · 0.45

Tested by

no test coverage detected