parse parses a statement from the given scanned tokens.
( depth int, sql string, tokens []sqlSymType, nakedIntType *types.T, )
| 201 | |
| 202 | // parse parses a statement from the given scanned tokens. |
| 203 | func (p *Parser) parse( |
| 204 | depth int, sql string, tokens []sqlSymType, nakedIntType *types.T, |
| 205 | ) (Statement, error) { |
| 206 | p.lexer.init(sql, tokens, nakedIntType) |
| 207 | defer p.lexer.cleanup() |
| 208 | if p.parserImpl.Parse(&p.lexer) != 0 { |
| 209 | if p.lexer.lastError == nil { |
| 210 | // This should never happen -- there should be an error object |
| 211 | // every time Parse() returns nonzero. We're just playing safe |
| 212 | // here. |
| 213 | p.lexer.Error("syntax error") |
| 214 | } |
| 215 | err := p.lexer.lastError |
| 216 | |
| 217 | // Compatibility with 19.1 telemetry: prefix the telemetry keys |
| 218 | // with the "syntax." prefix. |
| 219 | // TODO(knz): move the auto-prefixing of feature names to a |
| 220 | // higher level in the call stack. |
| 221 | tkeys := errors.GetTelemetryKeys(err) |
| 222 | if len(tkeys) > 0 { |
| 223 | for i := range tkeys { |
| 224 | tkeys[i] = "syntax." + tkeys[i] |
| 225 | } |
| 226 | err = errors.WithTelemetry(err, tkeys...) |
| 227 | } |
| 228 | |
| 229 | return Statement{}, err |
| 230 | } |
| 231 | return Statement{ |
| 232 | AST: p.lexer.stmt, |
| 233 | SQL: sql, |
| 234 | NumPlaceholders: p.lexer.numPlaceholders, |
| 235 | NumAnnotations: p.lexer.numAnnotations, |
| 236 | }, nil |
| 237 | } |
| 238 | |
| 239 | // unaryNegation constructs an AST node for a negation. This attempts |
| 240 | // to preserve constant NumVals and embed the negative sign inside |
no test coverage detected