parse parses a statement from the given scanned tokens.
( depth int, sql string, tokens []sqlSymType, nakedIntType *types.T, )
| 173 | |
| 174 | // parse parses a statement from the given scanned tokens. |
| 175 | func (p *Parser) parse( |
| 176 | depth int, sql string, tokens []sqlSymType, nakedIntType *types.T, |
| 177 | ) (statements.Statement[tree.Statement], error) { |
| 178 | p.lexer.init(sql, tokens, nakedIntType) |
| 179 | defer p.lexer.cleanup() |
| 180 | if p.parserImpl.Parse(&p.lexer) != 0 { |
| 181 | if p.lexer.lastError == nil { |
| 182 | // This should never happen -- there should be an error object |
| 183 | // every time Parse() returns nonzero. We're just playing safe |
| 184 | // here. |
| 185 | p.lexer.Error("syntax error") |
| 186 | } |
| 187 | err := p.lexer.lastError |
| 188 | |
| 189 | // Compatibility with 19.1 telemetry: prefix the telemetry keys |
| 190 | // with the "syntax." prefix. |
| 191 | // TODO(knz): move the auto-prefixing of feature names to a |
| 192 | // higher level in the call stack. |
| 193 | tkeys := errors.GetTelemetryKeys(err) |
| 194 | if len(tkeys) > 0 { |
| 195 | for i := range tkeys { |
| 196 | tkeys[i] = "syntax." + tkeys[i] |
| 197 | } |
| 198 | err = errors.WithTelemetry(err, tkeys...) |
| 199 | } |
| 200 | |
| 201 | return statements.Statement[tree.Statement]{}, err |
| 202 | } |
| 203 | |
| 204 | return statements.Statement[tree.Statement]{ |
| 205 | AST: p.lexer.stmt, |
| 206 | SQL: sql, |
| 207 | Comments: p.scanner.Comments, |
| 208 | NumPlaceholders: p.lexer.numPlaceholders, |
| 209 | NumAnnotations: p.lexer.numAnnotations, |
| 210 | }, nil |
| 211 | } |
| 212 | |
| 213 | // unaryNegation constructs an AST node for a negation. This attempts |
| 214 | // to preserve constant NumVals and embed the negative sign inside |
no test coverage detected