MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / parseWithDepth

Method parseWithDepth

pkg/sql/parser/parse.go:149–172  ·  view source on GitHub ↗
(
	depth int, sql string, nakedIntType *types.T, cm commentsMode,
)

Source from the content-addressed store, hash-verified

147)
148
149func (p *Parser) parseWithDepth(
150 depth int, sql string, nakedIntType *types.T, cm commentsMode,
151) (statements.Statements, error) {
152 stmts := statements.Statements(p.stmtBuf[:0])
153 p.scanner.Init(sql)
154 if cm == retainComments {
155 p.scanner.RetainComments()
156 }
157 defer p.scanner.Cleanup()
158 for {
159 sql, tokens, done := p.scanOneStmt()
160 stmt, err := p.parse(depth+1, sql, tokens, nakedIntType)
161 if err != nil {
162 return nil, err
163 }
164 if stmt.AST != nil {
165 stmts = append(stmts, stmt)
166 }
167 if done {
168 break
169 }
170 }
171 return stmts, nil
172}
173
174// parse parses a statement from the given scanned tokens.
175func (p *Parser) parse(

Callers 4

ParseMethod · 0.95
ParseWithIntMethod · 0.95
parseOneWithIntMethod · 0.95
ParseWithIntFunction · 0.95

Calls 6

scanOneStmtMethod · 0.95
parseMethod · 0.95
StatementsTypeAlias · 0.92
RetainCommentsMethod · 0.80
CleanupMethod · 0.80
InitMethod · 0.45

Tested by

no test coverage detected